Changes in ipc.c [edc767b:171ef85]
Legend:
- Unmodified
- Added
- Removed
-
ipc.c
redc767b r171ef85 209 209 } 210 210 211 /* Return just one line. Returns NULL if something broke, an empty string212 on temporary "errors" (EAGAIN and friends). */213 211 static char *ipc_readline( int fd ) 214 212 { 215 char buf[513], *eol;213 char *buf, *eol; 216 214 int size; 215 216 buf = g_new0( char, 513 ); 217 217 218 218 /* Because this is internal communication, it should be pretty safe … … 221 221 sockets and limites message length, messages should always be 222 222 complete. Saves us quite a lot of code and buffering. */ 223 size = recv( fd, buf, sizeof( buf ) - 1, MSG_PEEK );223 size = recv( fd, buf, 512, MSG_PEEK ); 224 224 if( size == 0 || ( size < 0 && !sockerr_again() ) ) 225 225 return NULL; … … 229 229 buf[size] = 0; 230 230 231 if( ( eol = strstr( buf, "\r\n" ) ) == NULL ) 231 eol = strstr( buf, "\r\n" ); 232 if( eol == NULL ) 232 233 return NULL; 233 234 else 234 235 size = eol - buf + 2; 236 237 g_free( buf ); 238 buf = g_new0( char, size + 1 ); 235 239 236 240 if( recv( fd, buf, size, 0 ) != size ) 237 241 return NULL; 238 242 else 239 return g_strndup( buf, size - 2 ); 243 buf[size-2] = 0; 244 245 return buf; 240 246 } 241 247 … … 248 254 cmd = irc_parse_line( buf ); 249 255 if( cmd ) 250 {251 256 ipc_command_exec( data, cmd, ipc_master_commands ); 252 g_free( cmd );253 }254 g_free( buf );255 257 } 256 258 else … … 270 272 cmd = irc_parse_line( buf ); 271 273 if( cmd ) 272 {273 274 ipc_command_exec( data, cmd, ipc_child_commands ); 274 g_free( cmd );275 }276 g_free( buf );277 275 } 278 276 else
Note: See TracChangeset
for help on using the changeset viewer.