
|
If you were logged in you would be able to see more operations.
|
|
|
Loudmouth
Created: 13/Apr/07 06:21 PM
Updated: 24/Sep/08 03:06 PM
|
|
| Component/s: |
None
|
| Affects Version/s: |
1.2.1
|
| Fix Version/s: |
1.3.4
|
|
|
On retries due to errors, the file descriptor is not closed in lm-connection.c:
If in _lm_connection_failed_with_error(...), the condition (connect_data->current_addr == NULL) is false,
connection_do_connect(...) is called and creates a new socket that is immediatly assigned with
connect_data->fd = fd, not closing the current fd if not 1. If the condition (connect_data>current_addr == NULL) is true,
connection_do_close(...) is called and fd set to -1 but was never closed.
|
|
Description
|
On retries due to errors, the file descriptor is not closed in lm-connection.c:
If in _lm_connection_failed_with_error(...), the condition (connect_data->current_addr == NULL) is false,
connection_do_connect(...) is called and creates a new socket that is immediatly assigned with
connect_data->fd = fd, not closing the current fd if not 1. If the condition (connect_data>current_addr == NULL) is true,
connection_do_close(...) is called and fd set to -1 but was never closed.
|
Show » |
|
retries; it happens on every failed connection. The real problem is described in a FIXME in
the current code.
if (connect_data->io_channel != NULL) { g_io_channel_unref (connect_data->io_channel); /* FIXME: need to check for last unref and close the socket */ }
(The FIXME, but no fix was added at some point between the 1.0.5 code
where I noticed the leak and 1.2.1; in 1.3.x the FIXME and bug have migrated to lm-socket.c)
In 1.2.1, there was also added in a couple of code paths an explicit call to _lm_sock_close()
apparently as a workaround for this? Without a lot of detailed analysis, I'd suggest one of
two fixes:
A) Just set the channel close_on_unref() immediately after creating it, and don't close the
socket in any other way.
B) Dont' use close_on_unref() (I presonally would never use close_on_unref() on an
iochannel where I'm mixing raw socket API with GIOChannel API) and add an internal
function that closes the socket, unrefs the channel and sets fd and sock to NULL.
[ Obviously fixing is cmplicated by the fact that 1.2.1 and 1.3.x have very different code
structure in this area. ]