-rw-r--r-- | src/eyefiworker.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/eyefiworker.cc b/src/eyefiworker.cc index ac75fc1..1979b46 100644 --- a/src/eyefiworker.cc +++ b/src/eyefiworker.cc | |||
@@ -18,58 +18,60 @@ | |||
18 | # include "iiidb.h" | 18 | # include "iiidb.h" |
19 | #endif | 19 | #endif |
20 | 20 | ||
21 | eyefiworker::eyefiworker() | 21 | eyefiworker::eyefiworker() |
22 | : eyefiService(SOAP_IO_STORE|SOAP_IO_KEEPALIVE) { | 22 | : eyefiService(SOAP_IO_STORE|SOAP_IO_KEEPALIVE) { |
23 | bind_flags = SO_REUSEADDR; max_keep_alive = 0; | 23 | bind_flags = SO_REUSEADDR; max_keep_alive = 0; |
24 | socket_flags = | 24 | socket_flags = |
25 | #if defined(MSG_NOSIGNAL) | 25 | #if defined(MSG_NOSIGNAL) |
26 | MSG_NOSIGNAL | 26 | MSG_NOSIGNAL |
27 | #elif defined(SO_NOSIGPIPE) | 27 | #elif defined(SO_NOSIGPIPE) |
28 | SO_NOSIGPIPE | 28 | SO_NOSIGPIPE |
29 | #else | 29 | #else |
30 | #error Something is wrong with sigpipe prevention on the platform | 30 | #error Something is wrong with sigpipe prevention on the platform |
31 | #endif | 31 | #endif |
32 | ; | 32 | ; |
33 | } | 33 | } |
34 | eyefiworker::~eyefiworker() { | ||
35 | } | ||
34 | 36 | ||
35 | int eyefiworker::run(int bindport) { | 37 | int eyefiworker::run(int bindport) { |
36 | #ifdef HAVE_SQLITE | 38 | #ifdef HAVE_SQLITE |
37 | sqlite3_initialize(); | 39 | sqlite3_initialize(); |
38 | #endif | 40 | #endif |
39 | if(!soap_valid_socket(bind(0,bindport,64))) | 41 | if(!soap_valid_socket(bind(0,bindport,64))) |
40 | throw std::runtime_error("failed to bind()"); | 42 | throw std::runtime_error("failed to bind()"); |
41 | signal(SIGCHLD,SIG_IGN); | 43 | signal(SIGCHLD,SIG_IGN); |
42 | while(true) { | 44 | while(true) { |
43 | if(!soap_valid_socket(accept())) | 45 | if(!soap_valid_socket(accept())) |
44 | throw std::runtime_error("failed to accept()"); | 46 | throw std::runtime_error("failed to accept()"); |
45 | pid_t p = fork(); | 47 | pid_t p = fork(); |
46 | if(p<0) throw std::runtime_error("failed to fork()"); | 48 | if(p<0) throw std::runtime_error("failed to fork()"); |
47 | if(!p) { | 49 | if(!p) { |
48 | recv_timeout = 600; send_timeout = 120; | 50 | recv_timeout = 600; send_timeout = 120; |
49 | (void)serve(); | 51 | (void)serve(); |
50 | soap_destroy(this); soap_end(this); soap_done(this); | 52 | soap_destroy(this); soap_end(this); soap_done(this); |
51 | #ifndef NDEBUG | 53 | #ifndef NDEBUG |
52 | struct rusage ru; | 54 | struct rusage ru; |
53 | if(getrusage(RUSAGE_SELF,&ru)) { | 55 | if(getrusage(RUSAGE_SELF,&ru)) { |
54 | syslog(LOG_NOTICE,"Failed to getrusage(): %d",errno); | 56 | syslog(LOG_NOTICE,"Failed to getrusage(): %d",errno); |
55 | }else{ | 57 | }else{ |
56 | syslog(LOG_INFO,"maxrss: %ld\n",ru.ru_maxrss); | 58 | syslog(LOG_INFO,"maxrss: %ld\n",ru.ru_maxrss); |
57 | } | 59 | } |
58 | #endif /* NDEBUG */ | 60 | #endif /* NDEBUG */ |
59 | _exit(0); | 61 | throw throwable_exit(0); |
60 | } | 62 | } |
61 | close(socket); socket = SOAP_INVALID_SOCKET; | 63 | close(socket); socket = SOAP_INVALID_SOCKET; |
62 | } | 64 | } |
63 | } | 65 | } |
64 | 66 | ||
65 | static binary_t session_nonce; | 67 | static binary_t session_nonce; |
66 | #ifdef HAVE_SQLITE | 68 | #ifdef HAVE_SQLITE |
67 | static struct { | 69 | static struct { |
68 | std::string filesignature; | 70 | std::string filesignature; |
69 | long filesize; | 71 | long filesize; |
70 | std::string filename; | 72 | std::string filename; |
71 | inline void reset() { filesignature.erase(); filename.erase(); filesize=0; } | 73 | inline void reset() { filesignature.erase(); filename.erase(); filesize=0; } |
72 | inline void set(const std::string n,const std::string sig,long siz) { | 74 | inline void set(const std::string n,const std::string sig,long siz) { |
73 | filename = n; filesignature = sig; filesize = siz; | 75 | filename = n; filesignature = sig; filesize = siz; |
74 | } | 76 | } |
75 | inline bool is(const std::string n,const std::string sig,long siz) { | 77 | inline bool is(const std::string n,const std::string sig,long siz) { |