Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Martin Sigwald
Will do. Thanks again to everyone. At least I learned how to use strace, which I didnt no. On Wed, Mar 24, 2010 at 2:25 PM, Pavel Ivanov wrote: > > When allocating memory for my ICMP packets I wasnt doind a bzero to fill > all > > fields with 0, so some "garbage" generated

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread David Baird
On Wed, Mar 24, 2010 at 11:19 AM, Martin Sigwald wrote: > Problem Solved: As some one point out, it was MY fault. > When allocating memory for my ICMP packets I wasnt doind a bzero to fill all > fields with 0, so some "garbage" generated by Sqlite use of memory was >

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Pavel Ivanov
> When allocating memory for my ICMP packets I wasnt doind a bzero to fill all > fields with 0, so some "garbage" generated by Sqlite use of memory was > "corrupting" my packets. And still try please my very first suggestion - run you program with valgrind (just to get used to it and to use it

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Martin Sigwald
Problem Solved: As some one point out, it was MY fault. When allocating memory for my ICMP packets I wasnt doind a bzero to fill all fields with 0, so some "garbage" generated by Sqlite use of memory was "corrupting" my packets. Thank you all for the help. One of the best user groups I ever met.

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread David Baird
On Wed, Mar 24, 2010 at 11:09 AM, Martin Sigwald wrote: > Doing N pings after a _close or a query has the same result as doind one: > not one of them works. Do 2 pings work ever? For example, how about each of these scenarios? open_db ping ping close_db or ping ping or

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Martin Sigwald
Doing N pings after a _close or a query has the same result as doind one: not one of them works. On Wed, Mar 24, 2010 at 2:07 PM, David Baird wrote: > On Wed, Mar 24, 2010 at 9:42 AM, Martin Sigwald > wrote: > > I meant socket. I know sockets are FDs. My

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread David Baird
On Wed, Mar 24, 2010 at 9:42 AM, Martin Sigwald wrote: > I meant socket. I know sockets are FDs. My mistake, sorry. > Yes, I tried putting the call before Sqlite calls and it works perfectly. If > I put it between open and close it works, provided I dont do anything else. >

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Martin Sigwald
I'm attaching the strace output for the following code you asked: int main(void){ sqlite3* db_handle=NULL; if(sqlite3_open("guido.db",_handle)) { //abro DB fprintf(stderr,"Error while open DB:%s\n",sqlite3_errmsg(db_handle)); printf("No pude abrir la

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread paivanof
> I don't notice any cases of where a stale file descriptor is being > accessed.  I'm stumped :-/ Can it be a problem with clone() calls? AFAIK, it's how SQLite checks if it can work safely from multiple threads. Martin, can you recompile SQLite with SQLITE_THREADSAFE set to 0 and look if your

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread David Baird
On Wed, Mar 24, 2010 at 9:24 AM, David Baird wrote: > On Wed, Mar 24, 2010 at 9:05 AM, Martin Sigwald wrote: >> While I could gather, both the open system called generated by the DB and >> the socket() syscall are returning a FD=3. >> That is, they are both

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Martin Sigwald
I meant socket. I know sockets are FDs. My mistake, sorry. Yes, I tried putting the call before Sqlite calls and it works perfectly. If I put it between open and close it works, provided I dont do anything else. For example, if I open the DB, ping, then run a query then ping again, the second ping

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread David Baird
On Wed, Mar 24, 2010 at 9:05 AM, Martin Sigwald wrote: > While I could gather, both the open system called generated by the DB and > the socket() syscall are returning a FD=3. > That is, they are both trying to use the same filedescriptor. My guess is > packets get sent to

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Jay A. Kreibich
On Wed, Mar 24, 2010 at 12:05:58PM -0300, Martin Sigwald scratched on the wall: > While I could gather, both the open system called generated by the DB and > the socket() syscall are returning a FD=3. > That is, they are both trying to use the same filedescriptor. My guess is > packets get sent to

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Martin Sigwald
While I could gather, both the open system called generated by the DB and the socket() syscall are returning a FD=3. That is, they are both trying to use the same filedescriptor. My guess is packets get sent to that file descriptor, instead of the port. How can I changed this? I just followed

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Martin Sigwald
I tried using STRACE, unfortunately, I am quite new to Linux programming, so I can't make much sense out of the output. I attached it to this email, in case some kind soul would like to take a look at it. The program ran is exactly this: #include #include #include #include "ping.h" int

Re: [sqlite] SQlite C API screwing port access?

2010-03-24 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Martin Sigwald wrote: > Here is the actual code: > > int main(void) > { > sqlite3* db_handle; > > sqlite3_open(DB_NAME,_handle); > sqlite3_close(db_handle); > my_ping("10.0.0.4"); > > return 0; > } > > If I call close

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Simon Slavin
On 23 Mar 2010, at 7:29pm, Martin Sigwald wrote: > DB_NAME equals "servers.db". > Both close and open return 0, my code catches a possible error, I didnt > included for legibility. > I tired using ":memory:", same result: cant ping. > These is quite frustrating. Hmm. Thanks for trying. If

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Martin Sigwald
DB_NAME equals "servers.db". Both close and open return 0, my code catches a possible error, I didnt included for legibility. I tired using ":memory:", same result: cant ping. These is quite frustrating. On Tue, Mar 23, 2010 at 4:23 PM, Simon Slavin wrote: > > On 23 Mar

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Simon Slavin
On 23 Mar 2010, at 7:06pm, Martin Sigwald wrote: > Here is the actual code: > > int main(void) > { >sqlite3* db_handle; > > sqlite3_open(DB_NAME,_handle); > sqlite3_close(db_handle); > my_ping("10.0.0.4"); > > return 0; > } > > If I call close after ping, it works.

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Martin Sigwald
Here is the actual code: int main(void) { sqlite3* db_handle; sqlite3_open(DB_NAME,_handle); sqlite3_close(db_handle); my_ping("10.0.0.4"); return 0; } If I call close after ping, it works. However, if besides of opening the DB I perform any query, ping doesnt work

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Matthew L. Creech
On Tue, Mar 23, 2010 at 12:55 PM, Martin Sigwald wrote: > I have a program which builds an ICMP package over IP and sends it. Before > that, I get IP number and other information from a SQlite DB. I was having > problems, so I began to comment different parts of the code,

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Pavel Ivanov
> Pavel: Yes, I allocate memory inside the ping function, but that is done > after calling de sqlite functions. There are no pointers shared between the > sqlite functions and the ping part. Actually I meant pointers shared between ping part and the part before calls to sqlite functions. Did you

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Martin Sigwald
I already tried that, and the first ping works while the second one doesn't, which validates my "screwing ports theory". Simon: Tried changing the DB_NAME and it didnt work either. Pavlov: Yes, I allocate memory inside the ping function, but that is done after calling de sqlite functions. There

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Teg
Hello Martin, Do the ping both before and after you open the DB. ping_server("10.0.0.4"); //my ping function, which pings a "hardcoded" IP, sqlite3_open(DB_NAME); sqlite3_close(DB_NAME); ping_server("10.0.0.4"); //my ping function, which pings a "hardcoded" IP, See if the first one works.

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Simon Slavin
On 23 Mar 2010, at 4:55pm, Martin Sigwald wrote: > sqlite3_open(DB_NAME); > sqlite3_close(DB_NAME); > > ping_server("10.0.0.4"); //my ping function, which pings a "hardcoded" IP, > doesnt interact with DB > > > If I run that code, the package nevers gets send (can't detect it with >

Re: [sqlite] SQlite C API screwing port access?

2010-03-23 Thread Pavel Ivanov
Does your pinging code involves some pointers to memory (strings or any other stuff) that could be already released before SQLite code is called? Try to run your program under valgrind and see whether it gives any errors. Pavel On Tue, Mar 23, 2010 at 12:55 PM, Martin Sigwald

[sqlite] SQlite C API screwing port access?

2010-03-23 Thread Martin Sigwald
I have a program which builds an ICMP package over IP and sends it. Before that, I get IP number and other information from a SQlite DB. I was having problems, so I began to comment different parts of the code, until I got to this code (pseudocode): sqlite3_open(DB_NAME); sqlite3_close(DB_NAME);