mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
fix double-dispose crash (but there's still a memory leak)
This commit is contained in:
parent
5c284fe6b0
commit
6c756533e3
1 changed files with 11 additions and 7 deletions
|
@ -829,6 +829,14 @@ typedef struct _SendQueueElem {
|
||||||
XP_U8* buf;
|
XP_U8* buf;
|
||||||
} SendQueueElem;
|
} SendQueueElem;
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_elem_proc( gpointer data )
|
||||||
|
{
|
||||||
|
SendQueueElem* elem = (SendQueueElem*)data;
|
||||||
|
free( elem->buf );
|
||||||
|
free( elem );
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
send_or_close( CommonGlobals* cGlobals, const XP_U8* buf, size_t len )
|
send_or_close( CommonGlobals* cGlobals, const XP_U8* buf, size_t len )
|
||||||
{
|
{
|
||||||
|
@ -842,12 +850,8 @@ send_or_close( CommonGlobals* cGlobals, const XP_U8* buf, size_t len )
|
||||||
cGlobals->socket = -1;
|
cGlobals->socket = -1;
|
||||||
|
|
||||||
/* delete all pending packets since the socket's bad */
|
/* delete all pending packets since the socket's bad */
|
||||||
GSList* iter;
|
g_slist_free_full( cGlobals->packetQueue, free_elem_proc );
|
||||||
for ( iter = cGlobals->packetQueue; !!iter; iter = iter->next ) {
|
cGlobals->packetQueue = NULL;
|
||||||
SendQueueElem* elem = (SendQueueElem*)iter->data;
|
|
||||||
free( elem->buf );
|
|
||||||
free( elem );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
LOG_RETURNF( "%d", success );
|
LOG_RETURNF( "%d", success );
|
||||||
return success;
|
return success;
|
||||||
|
@ -1056,7 +1060,7 @@ blocking_read( int fd, unsigned char* buf, int len )
|
||||||
{
|
{
|
||||||
int nRead = 0;
|
int nRead = 0;
|
||||||
while ( nRead < len ) {
|
while ( nRead < len ) {
|
||||||
XP_LOGF( "%s: blocking for %d bytes", __func__, len );
|
XP_LOGF( "%s(fd=%d): blocking for %d bytes", __func__, fd, len );
|
||||||
ssize_t siz = read( fd, buf + nRead, len - nRead );
|
ssize_t siz = read( fd, buf + nRead, len - nRead );
|
||||||
if ( siz <= 0 ) {
|
if ( siz <= 0 ) {
|
||||||
XP_LOGF( "read => %d, errno=%d (\"%s\")", nRead,
|
XP_LOGF( "read => %d, errno=%d (\"%s\")", nRead,
|
||||||
|
|
Loading…
Reference in a new issue