Skip to content

net_input_handler.c doesn't check for EINTR #11

@habnabit

Description

@habnabit

In

else if (result == -1) {
sqchat_buffer_print(network->buffer,
"Error: %s\n"
"Closing connection.\n",
strerror(errno));
close(network->socket);
finish_network_disconnect(network);
return FALSE;
it is assumed that any error returned indicates a fatal network problem. However, as http://linux.die.net/man/2/recv explains:

EINTR
The receive was interrupted by delivery of a signal before any data were available; see signal(7).

This is a recoverable failure; it merely means that the recv(2) call needs to be retried.

Somewhat relatedly,

else if (result == GNUTLS_E_INTERRUPTED ||
result == GNUTLS_E_AGAIN)
return TRUE;
does handle the same case for gnutls_read but it aborts the whole function with a return TRUE instead of just retrying the read with a continue. This is obviously less of a problem, since presumably glib will still sense that the socket has data ready to be read and re-call the whole function, but it seems like it would be simpler to instead simply retry the read.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions