... | ... |
@@ -265,8 +265,12 @@ int command(client_conn_t *conn, int *virus) |
265 | 265 |
thrmgr_setactivetask(NULL, "MULTISCAN"); |
266 | 266 |
type = TYPE_MULTISCAN; |
267 | 267 |
scandata.group = group = thrmgr_group_new(); |
268 |
- if (!group) |
|
269 |
- return CL_EMEM; |
|
268 |
+ if (!group) { |
|
269 |
+ if(optget(opts, "ExitOnOOM")->enabled) |
|
270 |
+ return -1; |
|
271 |
+ else |
|
272 |
+ return 1; |
|
273 |
+ } |
|
270 | 274 |
break; |
271 | 275 |
} |
272 | 276 |
case COMMAND_MULTISCANFILE: |
... | ... |
@@ -280,29 +284,34 @@ int command(client_conn_t *conn, int *virus) |
280 | 280 |
*virus = scandata.infected; |
281 | 281 |
if (ret == CL_BREAK) { |
282 | 282 |
thrmgr_group_terminate(conn->group); |
283 |
- return CL_BREAK; |
|
283 |
+ return 1; |
|
284 | 284 |
} |
285 | 285 |
return scandata.errors > 0 ? scandata.errors : 0; |
286 | 286 |
case COMMAND_FILDES: |
287 | 287 |
thrmgr_setactivetask(NULL, "FILDES"); |
288 | 288 |
#ifdef HAVE_FD_PASSING |
289 |
- if (conn->scanfd == -1) |
|
289 |
+ if (conn->scanfd == -1) { |
|
290 | 290 |
conn_reply_error(conn, "FILDES: didn't receive file descriptor."); |
291 |
+ return 1; |
|
292 |
+ } |
|
291 | 293 |
else { |
292 | 294 |
ret = scanfd(conn, NULL, engine, options, opts, desc, 0); |
293 | 295 |
if (ret == CL_VIRUS) { |
294 | 296 |
*virus = 1; |
297 |
+ ret = 0; |
|
295 | 298 |
} else if (ret == CL_EMEM) { |
296 | 299 |
if(optget(opts, "ExitOnOOM")->enabled) |
297 | 300 |
ret = -1; |
301 |
+ else |
|
302 |
+ ret = 1; |
|
298 | 303 |
} else if (ret == CL_ETIMEOUT) { |
299 | 304 |
thrmgr_group_terminate(conn->group); |
300 | 305 |
ret = 1; |
301 | 306 |
} else |
302 | 307 |
ret = 0; |
308 |
+ logg("$Closed fd %d\n", conn->scanfd); |
|
309 |
+ close(conn->scanfd); |
|
303 | 310 |
} |
304 |
- logg("$Closed fd %d\n", conn->scanfd); |
|
305 |
- close(conn->scanfd); |
|
306 | 311 |
return ret; |
307 | 312 |
#else |
308 | 313 |
conn_reply_error(conn, "FILDES support not compiled in."); |
... | ... |
@@ -323,6 +332,8 @@ int command(client_conn_t *conn, int *virus) |
323 | 323 |
if (ret == CL_EMEM) { |
324 | 324 |
if(optget(opts, "ExitOnOOM")->enabled) |
325 | 325 |
return -1; |
326 |
+ else |
|
327 |
+ return 1; |
|
326 | 328 |
} |
327 | 329 |
return 0; |
328 | 330 |
case COMMAND_INSTREAMSCAN: |
... | ... |
@@ -330,9 +341,12 @@ int command(client_conn_t *conn, int *virus) |
330 | 330 |
ret = scanfd(conn, NULL, engine, options, opts, desc, 1); |
331 | 331 |
if (ret == CL_VIRUS) { |
332 | 332 |
*virus = 1; |
333 |
+ ret = 0; |
|
333 | 334 |
} else if (ret == CL_EMEM) { |
334 | 335 |
if(optget(opts, "ExitOnOOM")->enabled) |
335 | 336 |
ret = -1; |
337 |
+ else |
|
338 |
+ ret = 1; |
|
336 | 339 |
} else if (ret == CL_ETIMEOUT) { |
337 | 340 |
thrmgr_group_terminate(conn->group); |
338 | 341 |
ret = 1; |
... | ... |
@@ -363,9 +377,12 @@ int command(client_conn_t *conn, int *virus) |
363 | 363 |
scandata.dev = sb.st_dev; |
364 | 364 |
|
365 | 365 |
ret = cli_ftw(conn->filename, flags, maxdirrec ? maxdirrec : INT_MAX, scan_callback, &data, scan_pathchk); |
366 |
- if (ret == CL_EMEM) |
|
366 |
+ if (ret == CL_EMEM) { |
|
367 | 367 |
if(optget(opts, "ExitOnOOM")->enabled) |
368 | 368 |
return -1; |
369 |
+ else |
|
370 |
+ return 1; |
|
371 |
+ } |
|
369 | 372 |
if (scandata.group && type == TYPE_MULTISCAN) { |
370 | 373 |
thrmgr_group_waitforall(group, &ok, &error, &total); |
371 | 374 |
pthread_mutex_lock(&conn->thrpool->pool_mutex); |