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 <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
#include "ping.h"

int main(void){
    sqlite3* db_handle=NULL;

    ping_pong("10.0.0.3",2); //IP number + timeout in seconds --> This pings
works fine

if(sqlite3_open("guido.db",&db_handle))
        {
            fprintf(stderr,"Error while opening
DB:%s\n",sqlite3_errmsg(db_handle));
            exit(1);
        }
 if(sqlite3_close(db_handle))
        {
            fprintf(stderr,"Error while closing
DB:%s\n",sqlite3_errmsg(db_handle));
            exit(1);
        }
    ping_pong("10.0.0.3",2); // This ping doesnt work
    return 0;
}

On Wed, Mar 24, 2010 at 4:51 AM, Roger Binns <rog...@rogerbinns.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Martin Sigwald wrote:
> > Here is the actual code:
> >
> > int main(void)
> > {
> >     sqlite3* db_handle;
> >
> >      sqlite3_open(DB_NAME,&db_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 either.
>
> My best guess is that you are making an error with file descriptors.  It
> can be quite easy to accidentally use various values with low numbers
> instead of the actual file descriptor numbers, and you'll get away with
> it until some other code (eg sqlite) opens and closes files.  (Note that
> under some circumstances SQLite can leave file descriptors open even
> after close is called.)
>
> I suggest using strace and carefully examining the file descriptors used.
>
> Roger
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkupxGUACgkQmOOfHg372QTd2ACeNaCEFII4TuVK8ZtTpCvZeFeX
> ivYAnjuLh8uKl1z1jVauy9Fxa60Po9RR
> =AVyR
> -----END PGP SIGNATURE-----
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
execve("./miercoles.o", ["./miercoles.o"], [/* 22 vars */]) = 0
brk(0)                                  = 0x804b000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7f17000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=49519, ...}) = 0
mmap2(NULL, 49519, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f0a000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/usr/lib/libsqlite3.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20\316"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=410036, ...}) = 0
mmap2(NULL, 413188, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0xb7ea5000
mmap2(0xb7f08000, 8192, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x62) = 0xb7f08000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260e\1"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1364388, ...}) = 0
mmap2(NULL, 1369712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0xb7d56000
mmap2(0xb7e9f000, 12288, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x149) = 0xb7e9f000
mmap2(0xb7ea2000, 9840, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7ea2000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p\n\0\000"..., 512) = 
512
fstat64(3, {st_mode=S_IFREG|0644, st_size=9684, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7d55000
mmap2(NULL, 12412, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0xb7d51000
mmap2(0xb7d53000, 8192, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb7d53000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20H\0\000"..., 512) = 
512
fstat64(3, {st_mode=S_IFREG|0755, st_size=112354, ...}) = 0
mmap2(NULL, 94688, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0xb7d39000
mmap2(0xb7d4d000, 8192, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13) = 0xb7d4d000
mmap2(0xb7d4f000, 4576, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7d4f000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7d38000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7d386b0, limit:1048575, 
seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, 
useable:1}) = 0
mprotect(0xb7e9f000, 4096, PROT_READ)   = 0
munmap(0xb7f0a000, 49519)               = 0
set_tid_address(0xb7d386f8)             = 6239
set_robust_list(0xb7d38700, 0xc)        = 0
futex(0xbfd645c0, 0x81 /* FUTEX_??? */, 1) = 0
rt_sigaction(SIGRTMIN, {0xb7d3d2c0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb7d3d340, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
uname({sys="Linux", node="martin-laptop", ...}) = 0
getuid32()                              = 0
brk(0)                                  = 0x804b000
brk(0x806c000)                          = 0x806c000
socket(PF_INET, SOCK_RAW, IPPROTO_ICMP) = 3
setsockopt(3, SOL_IP, IP_HDRINCL, [1], 4) = 0
sendto(3, "E\0\34\0Eg\0\0\377\1P\223\0\0\0\0\n\0\0\3\10\0;\320#\306"..., 28, 0, 
{sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.0.0.3")}, 16) = 28
select(4, [3], NULL, NULL, {2, 500000}) = 1 (in [3], left {2, 496000})
recvfrom(3, "e\0\0\0...@\0\0@\0015\233\n\0\0\3\n\0\0\4\0\0C\320#\306"..., 28, 
0, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.0.0.3")}, 
[16]) = 28
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7f16000
write(1, "El Server 10.0.0.3 esta en el es"..., 43) = 43
close(3)                                = 0
getcwd("/home/martin", 5000)            = 13
open("/home/martin/guido.db", O_RDWR|O_CREAT|O_LARGEFILE, 0644) = 3
fcntl64(3, F_GETFD)                     = 0
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
fstat64(3, {st_mode=S_IFREG|0777, st_size=2048, ...}) = 0
dup(3)                                  = 4
mmap2(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7537000
mprotect(0xb7537000, 4096, PROT_NONE)   = 0
clone(child_stack=0xb7d374c4, 
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,
 parent_tidptr=0xb7d37bd8, {entry_number:6, base_addr:0xb7d37b90, 
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, 
seg_not_present:0, useable:1}, child_tidptr=0xb7d37bd8) = 6240
mmap2(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb6d36000
mprotect(0xb6d36000, 4096, PROT_NONE)   = 0
clone(child_stack=0xb75364c4, 
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,
 parent_tidptr=0xb7536bd8, {entry_number:6, base_addr:0xb7536b90, 
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, 
seg_not_present:0, useable:1}, child_tidptr=0xb7536bd8) = 6241
close(4)                                = 0
_llseek(3, 0, [0], SEEK_SET)            = 0
read(3, "SQLite format 3\0\4\0\1\1\0@  \0\0\0\4\0\0\0\0"..., 100) = 100
close(3)                                = 0
getuid32()                              = 0
socket(PF_INET, SOCK_RAW, IPPROTO_ICMP) = 3
setsockopt(3, SOL_IP, IP_HDRINCL, [1], 4) = 0
sendto(3, "E\0\34\0Hs\4\10\377\1I\177\0\0\0\0\n\0\0\3\10\0\276\256"..., 28, 0, 
{sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.0.0.3")}, 16) = 28
select(4, [3], NULL, NULL, {2, 500000}) = 0 (Timeout)
write(1, "TIMEOUT\n", 8)                = 8
close(3)                                = 0
exit_group(0)                           = ?
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to