summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2013-02-12 18:22:58 (UTC)
committer Michael Krelin <hacker@klever.net>2013-02-12 18:22:58 (UTC)
commitb1f275528c0a5502d9739948f131a0993f90cfbc (patch) (unidiff)
tree812d368dd68122f24113581b2dc5274b16b4385a
parent91205e0ea02ea55a5f9d2d9cde4e51ede5258afe (diff)
downloadiii-b1f275528c0a5502d9739948f131a0993f90cfbc.zip
iii-b1f275528c0a5502d9739948f131a0993f90cfbc.tar.gz
iii-b1f275528c0a5502d9739948f131a0993f90cfbc.tar.bz2
report resource consumption before exiting child
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyefiworker.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/eyefiworker.cc b/src/eyefiworker.cc
index 9dcd048..450661a 100644
--- a/src/eyefiworker.cc
+++ b/src/eyefiworker.cc
@@ -1,13 +1,17 @@
1#include <signal.h> 1#include <signal.h>
2#ifndef NDEBUG
3# include <sys/resource.h>
4#endif
5#include <syslog.h>
2#include <stdexcept> 6#include <stdexcept>
3#include "eyefiworker.h" 7#include "eyefiworker.h"
4#ifdef HAVE_SQLITE 8#ifdef HAVE_SQLITE
5# include "sqlite3.h" 9# include "sqlite3.h"
6#endif 10#endif
7 11
8eyefiworker::eyefiworker() 12eyefiworker::eyefiworker()
9 : eyefiService(SOAP_IO_STORE|SOAP_IO_KEEPALIVE) { 13 : eyefiService(SOAP_IO_STORE|SOAP_IO_KEEPALIVE) {
10 bind_flags = SO_REUSEADDR; max_keep_alive = 0; 14 bind_flags = SO_REUSEADDR; max_keep_alive = 0;
11 socket_flags = 15 socket_flags =
12#if defined(MSG_NOSIGNAL) 16#if defined(MSG_NOSIGNAL)
13 MSG_NOSIGNAL 17 MSG_NOSIGNAL
@@ -26,17 +30,25 @@ int eyefiworker::run(int bindport) {
26 if(!soap_valid_socket(bind(0,bindport,64))) 30 if(!soap_valid_socket(bind(0,bindport,64)))
27 throw std::runtime_error("failed to bind()"); 31 throw std::runtime_error("failed to bind()");
28 signal(SIGCHLD,SIG_IGN); 32 signal(SIGCHLD,SIG_IGN);
29 while(true) { 33 while(true) {
30 if(!soap_valid_socket(accept())) 34 if(!soap_valid_socket(accept()))
31 throw std::runtime_error("failed to accept()"); 35 throw std::runtime_error("failed to accept()");
32 pid_t p = fork(); 36 pid_t p = fork();
33 if(p<0) throw std::runtime_error("failed to fork()"); 37 if(p<0) throw std::runtime_error("failed to fork()");
34 if(!p) { 38 if(!p) {
35 recv_timeout = 600; send_timeout = 120; 39 recv_timeout = 600; send_timeout = 120;
36 (void)serve(); 40 (void)serve();
37 soap_destroy(this); soap_end(this); soap_done(this); 41 soap_destroy(this); soap_end(this); soap_done(this);
42#ifndef NDEBUG
43 struct rusage ru;
44 if(getrusage(RUSAGE_SELF,&ru)) {
45 syslog(LOG_NOTICE,"Failed to getrusage(): %d",errno);
46 }else{
47 syslog(LOG_INFO,"maxrss: %ld\n",ru.ru_maxrss);
48 }
49#endif /* NDEBUG */
38 _exit(0); 50 _exit(0);
39 } 51 }
40 close(socket); socket = SOAP_INVALID_SOCKET; 52 close(socket); socket = SOAP_INVALID_SOCKET;
41 } 53 }
42} 54}