Re: [gnet] Is it ok to call gnet_tcp_socket_delete() in child process?



I had read the UNP(stevens). But my question was related
to GTcpSocket objects. My question was: "should I use 
gnet_tcp_socket_delete() or close() on associated socket
in child process?" Or in other words "is it safe to call
gnet_tcp_socket_delete() in child process when parent might
be using data pointed (internally) by this object?"

cheers
vrihad 


 --- On Fri 05/23, David A. Helder < dhelder umich edu > wrote:
From: David A. Helder [mailto: dhelder umich edu]
To: vrihad myway com
Date: 23 May 2003 11:07:22 -0400
Subject: Re: [gnet] Is it ok to call gnet_tcp_socket_delete() in child process?

<br>The OS has a reference counter for each file descriptor.  You can (and<br>should) delete the unused GTcpSockets.<br><br>Steven's UNP covers this.<br><br>David<br><br><br>On Fri, 2003-05-23 at 09:24, Vrihad Shoonya wrote:<br>> Dear pals,<br>> <br>> I have a doubt regarding deleting a gnet tcp socket object.<br>> I am working on a network app where I am calling the function<br>> gnet_tcp_socket_server_accept_async(sock, handler, NULL).<br>> In the handler() I am calling fork() after checking for some<br>> conditions. Just after this point, in the parent process I need<br>> to close the connection socket while in the child I need to<br>> close listening socket.<br>> <br>> Since I am dealing with gnet_tcp_socket, is it ok if I call<br>> gnet_tcp_soket_delete() with respective socket objects? Or on<br>> the other hand should I call close(fd) where fd is the file <br>> descriptor obtained from concerned gnet_tcp_socket?<br>><br>> The question arises because as per my understanding, when fork()<br>> is called, kernel just makes an image of the running process<br>> and duplicates the open file descriptors for child. This means <br>> all data is duplicated. If some data is pointing to some memory <br>> location in parent process, it remains that way in child too. <br>> So internal pointers held by components in gnet framework in<br>> both the processes are still pointing to the same locations in <br>> memory. Is my understanding correct? Pointers to further<br>> information in this regard is appreciated.<br><br><br><br>-- <br>David Helder - dhelder umich edu - http://www.eecs.umich.edu/~dhelder<br><br>

_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]