[Freeciv-Dev] Re: (PR#3901) bug no. 3664
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sun, 30 Mar 2003, Peter Zelezny wrote:
> Hi,
Hello! :-)
> Regarding this bug:
>
> http://rt.freeciv.org/Ticket/Display.html?id=3664
>
> I think this patch might be on the right track to fixing it. I havn't had
> a chance to try it out (I havn't the resources).
>
> Basically, you want to:
>
> loop
> {
> select(.., &write_fd, ....); /* sernet.c */
>
> if(FD_IS_SET(socket, &write))
> {
> repeat /* connection.c */
> {
> nput = send(...);
> if(nput == -1 && errno==EWOULDBLOCK)
> break;
> }
> }
> }
>
> I think the second call to select() in connection.c is incorrect and
You mean the select in common/connection.c line 187?
Here is the code for that one:
for (start=0; buf->ndata-start>limit;) { // A)
...
MY_FD_ZERO(&writefs);
MY_FD_ZERO(&exceptfs);
FD_SET(pc->sock, &writefs);
FD_SET(pc->sock, &exceptfs);
tv.tv_sec = 0; tv.tv_usec = 0;
if (select(pc->sock+1, NULL, &writefs, &exceptfs, &tv) <= 0) {
break;
}
...
if (FD_ISSET(pc->sock, &writefs)) {
nblock=MIN(buf->ndata-start, MAX_LEN_PACKET);
if((nput=write(pc->sock, buf->data+start, nblock)) == -1) {
if (errno == EWOULDBLOCK || errno == EAGAIN) {
break;
}
...
}
start += nput;
}
...
}
> could block. Also, you shouldn't put sockets into write_fd unless there's
How come it could block? The timeout for that select() is 0.
At most you won't be able to write as much as you could in case your
assertion about select() not always returning true on availability to write
is true. If that happens select() will return 0 and the loop ends.
> actually something in your queue to send, or select can keep returning
> and loop (on some unix's it does this). I'm not sure if it does it or
> not, just FYI.
If there is nothing to send the loop will not be entered at all and
select() will never be called. See A).
Cheers,
---
Vasco Alexandre da Silva Costa @ Instituto Superior Tecnico, Lisboa
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#3901) bug no. 3664,
Vasco Alexandre da Silva Costa <=
|
|