Browse code

Cleanup local socket and clamd.run on exit

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@362 77e5149b-7576-45b1-b177-96237e5ba77b

Trog authored on 2004/03/01 22:01:49
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Mar  1 13:08:04 GMT 2004 (trog)
2
+-----------------------------------
3
+  * clamd: Cleanup local socket and clamd.run on exit
4
+
1 5
 Mon Mar  1 01:25:03 GMT 2004 (njh)
2 6
 ----------------------------------
3 7
   * clamav-milter:	Removed duplicate /etc/rc.d/init.d/clamd that had
... ...
@@ -338,7 +338,7 @@ int acceptloop_th(int socketd, struct cl_node *root, const struct cfgstruct *cop
338 338
 	pthread_create(&clamuko_pid, &clamuko_attr, clamukoth, tharg);
339 339
     }
340 340
 #else
341
-	logg("!Clamuko is not available.\n");
341
+	logg("Clamuko is not available.\n");
342 342
 #endif
343 343
 
344 344
     /* set up signal handling */
... ...
@@ -464,6 +464,24 @@ int acceptloop_th(int socketd, struct cl_node *root, const struct cfgstruct *cop
464 464
 	pthread_join(clamuko_pid, NULL);
465 465
     }
466 466
 #endif
467
+    logg("*Shutting down the main socket.\n");
468
+    shutdown(socketd, 2);
469
+    logg("*Closing the main socket.\n");
470
+    close(socketd);
471
+    if((cpt = cfgopt(copt, "LocalSocket"))) {
472
+	if(unlink(cpt->strarg) == -1)
473
+	    logg("!Can't unlink the socket file %s\n", cpt->strarg);
474
+	else
475
+	     logg("Socket file removed.\n");
476
+	}
477
+
478
+    if((cpt = cfgopt(copt, "PidFile"))) {
479
+	if(unlink(cpt->strarg) == -1)
480
+	    logg("!Can't unlink the pid file %s\n", cpt->strarg);
481
+	else
482
+	    logg("Pid file removed.\n");
483
+    }
484
+
467 485
     logg("Exiting (clean)\n");
468 486
     return 0;
469 487
 }