X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=amandad-src%2Famandad.c;fp=amandad-src%2Famandad.c;h=d864c3fa1bc7ca511ac93374fbccf9004a8d87f6;hb=d28952249e392eb31bc8eecc53f6c477f30c617b;hp=11009d854ef405fbbfd443427c61e2bfba83e9ab;hpb=949b8910a5e23c4285d0b1aedacfc82a14dc97a5;p=debian%2Famanda diff --git a/amandad-src/amandad.c b/amandad-src/amandad.c index 11009d8..d864c3f 100644 --- a/amandad-src/amandad.c +++ b/amandad-src/amandad.c @@ -1,6 +1,7 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver * Copyright (c) 1991-1999 University of Maryland at College Park + * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved. * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -151,7 +152,7 @@ struct active_service { */ GSList *serviceq = NULL; -static int wait_30s = 1; +static event_handle_t *exit_event; static int exit_on_qlength = 1; static char *auth = NULL; static kencrypt_type amandad_kencrypt = KENCRYPT_NONE; @@ -451,7 +452,6 @@ main( strcasecmp(auth, "ssh") == 0 || strcasecmp(auth, "local") == 0 || strcasecmp(auth, "bsdtcp") == 0) { - wait_30s = 0; exit_on_qlength = 1; } @@ -504,8 +504,7 @@ main( * Schedule an event that will try to exit every 30 seconds if there * are no requests outstanding. */ - if(wait_30s) - (void)event_register((event_id_t)30, EV_TIME, exit_check, &no_exit); + exit_event = event_register((event_id_t)30, EV_TIME, exit_check, &no_exit); /* * Call event_loop() with an arg of 0, telling it to block until all @@ -544,6 +543,7 @@ exit_check( if (no_exit) return; + g_debug("timeout exit"); dbclose(); exit(0); } @@ -571,7 +571,12 @@ protocol_accept( /* * If handle is NULL, then the connection is closed. */ - if(handle == NULL) { + if (handle == NULL) { + if (exit_on_qlength && exit_event) { + /* remove the timeout, we will exit once the service terminate */ + event_release(exit_event); + exit_event = NULL; + } return; } @@ -1481,9 +1486,7 @@ process_writenetfd( dbprintf(_("process_writenetfd: dh->fd_write <= 0\n")); } else if (size > 0) { full_write(dh->fd_write, buf, (size_t)size); - security_stream_read(dh->netfd, process_writenetfd, dh); - } - else { + } else { aclose(dh->fd_write); } }