mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
([TcpInPort -receivePacketWithTimeout:]): Move initialization of
select_timeout to inside loop since Linux select() modifies *select_timeout. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1095 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6c6372b7f1
commit
e31ac21a93
1 changed files with 22 additions and 10 deletions
|
@ -308,20 +308,28 @@ static NSMapTable* port_number_2_port;
|
|||
|
||||
assert (is_valid);
|
||||
|
||||
/* If MILLISECONDS is less than 0, wait forever. */
|
||||
if (milliseconds >= 0)
|
||||
{
|
||||
timeout.tv_sec = milliseconds / 1000;
|
||||
timeout.tv_usec = (milliseconds % 1000) * 1000;
|
||||
select_timeout = &timeout;
|
||||
}
|
||||
else
|
||||
select_timeout = NULL;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Set the file descriptors select() will wait on. */
|
||||
read_fd_set = active_fd_set;
|
||||
|
||||
/* Set the amount of time to wait. */
|
||||
/* Linux select() modifies *select_timeout to reflect the
|
||||
amount of time not slept, so we have to re-initialize it
|
||||
each time. */
|
||||
/* If MILLISECONDS is less than 0, wait forever. */
|
||||
if (milliseconds >= 0)
|
||||
{
|
||||
timeout.tv_sec = milliseconds / 1000;
|
||||
timeout.tv_usec = (milliseconds % 1000) * 1000;
|
||||
select_timeout = &timeout;
|
||||
}
|
||||
else
|
||||
select_timeout = NULL;
|
||||
|
||||
/* Wait for incoming data. */
|
||||
sel_ret = select (FD_SETSIZE, &read_fd_set, NULL, NULL, select_timeout);
|
||||
|
||||
if (sel_ret < 0)
|
||||
{
|
||||
perror ("[TcpInPort receivePacketWithTimeout:] select()");
|
||||
|
@ -502,6 +510,8 @@ static NSMapTable* port_number_2_port;
|
|||
}
|
||||
assert (!NSCountMapTable (client_sock_2_out_port));
|
||||
|
||||
/* xxx Perhaps should delay this close() to keep another port from
|
||||
getting it. This may help Connection invalidation confusion. */
|
||||
close (_socket);
|
||||
|
||||
/* These are here, and not in -dealloc, to prevent
|
||||
|
@ -886,6 +896,8 @@ static NSMapTable *out_port_bag = NULL;
|
|||
{
|
||||
assert (is_valid);
|
||||
|
||||
/* xxx Perhaps should delay this close() to keep another port from
|
||||
getting it. This may help Connection invalidation confusion. */
|
||||
if (close (_socket) < 0)
|
||||
{
|
||||
perror ("[TcpOutPort -invalidate] close()");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue