On Wed, Mar 24, 2010 at 9:05 AM, Martin Sigwald <msigw...@gmail.com> 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 that file descriptor, instead of the port. How can I
> changed this? I just followed standar procedure to allocate a socket:
> sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP))
>
> Shouldn't the Kernel take care of this and provide an unused FD??

According to the strace, the kernel is taking care of that properly.
You get a socket, call sendto, select, recvfrom, then close it.  And
then you open guido.db.  Since you just closed your socket, the fd=3
is reused for guido.db.  This is perfectly legitimate.  Something else
funny is going on.  Here's the relevant portions from the strace:

Socket is opened and closed here:

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

...and then database is opened here:

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
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to