Changeset 4156
- Timestamp:
- 12/19/10 01:08:48 (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals.h
r4144 r4156 1294 1294 1295 1295 // oscam 1296 extern void cs_exit_oscam(); 1297 extern void cs_restart_oscam(); 1296 1298 extern int recv_from_udpipe(uchar *); 1297 1299 extern char* username(struct s_client *); -
trunk/oscam-config.h
r4140 r4156 8 8 9 9 #ifndef WITH_SSL 10 //#define WITH_SSL10 #define WITH_SSL 11 11 #endif 12 12 -
trunk/oscam-http.c
r4155 r4156 2270 2270 running = 0; 2271 2271 2272 struct s_client *cl; 2273 for (cl=first_client->next; cl ; cl=cl->next) 2274 kill_thread(cl); 2275 exit(SIGQUIT); 2272 cs_exit_oscam(); 2273 } 2274 else if (strcmp(getParam(params, "action"), "Restart") == 0) { 2275 tpl_addVar(vars, 0, "STYLESHEET", CSS); 2276 tpl_printf(vars, 0, "REFRESHTIME", "%d", 1); 2277 tpl_addVar(vars, 0, "REFRESHURL", "status.html"); 2278 tpl_addVar(vars, 0, "REFRESH", tpl_getTpl(vars, "REFRESH")); 2279 tpl_printf(vars, 0, "SECONDS", "%d", 1); 2280 webif_write(tpl_getTpl(vars, "SHUTDOWN"), f); 2281 running = 0; 2282 2283 cs_restart_oscam(); 2284 2276 2285 } else { 2277 2286 webif_write(tpl_getTpl(vars, "PRESHUTDOWN"), f); … … 2990 2999 cs_log("HTTP Server: Shutdown requested from %s", inet_ntoa(*(struct in_addr *)&remote.sin_addr)); 2991 3000 close(sock); 2992 exit(SIGQUIT);3001 //exit(SIGQUIT); 2993 3002 } 2994 3003 #endif -
trunk/oscam.c
r4151 r4156 20 20 Globals 21 21 *****************************************************************************/ 22 int exit_oscam=0; 22 23 struct s_module ph[CS_MAX_MOD]; // Protocols 23 24 struct s_cardsystem cardsystem[CS_MAX_MOD]; // Protocols … … 574 575 575 576 NULLFREE(cl); 576 577 exit(sig); //clears all threads578 577 } 579 578 … … 2997 2996 } 2998 2997 2998 #ifdef WEBIF 2999 static void restart_daemon() 3000 { 3001 while (1) { 3002 3003 //start client process: 3004 pid_t pid = fork(); 3005 if (!pid) 3006 return; //client process=oscam process 3007 if (pid < 0) 3008 exit(1); 3009 3010 //restart control process: 3011 int res=0; 3012 int status=0; 3013 do { 3014 res = waitpid(pid, &status, 0); 3015 if (res==-1) { 3016 if (errno!=EINTR) 3017 exit(1); 3018 } 3019 } while (res!=pid); 3020 3021 status = WEXITSTATUS(status); 3022 3023 //status=99 restart oscam, all other->terminate 3024 if (status!=99) { 3025 exit(status); 3026 } 3027 } 3028 } 3029 #endif 2999 3030 3000 3031 int main (int argc, char *argv[]) 3001 3032 { 3002 3003 3033 3004 3034 if (pthread_key_create(&getclient, NULL)) { … … 3126 3156 } 3127 3157 } 3158 3159 #ifdef OS_MACOSX 3160 if (bg && daemon_compat(1,0)) 3161 #else 3162 if (bg && daemon(1,0)) 3163 #endif 3164 { 3165 cs_log("Error starting in background (errno=%d: %s)", errno, strerror(errno)); 3166 cs_exit(1); 3167 } 3168 3169 #ifdef WEBIF 3170 restart_daemon(); 3171 #endif 3172 3128 3173 if (cs_confdir[strlen(cs_confdir)]!='/') strcat(cs_confdir, "/"); 3129 3174 init_shm(); … … 3173 3218 first_client->fd_m2c_c=mfdr; 3174 3219 3175 #ifdef OS_MACOSX3176 if (bg && daemon_compat(1,0))3177 #else3178 if (bg && daemon(1,0))3179 #endif3180 {3181 cs_log("Error starting in background (errno=%d: %s)", errno, strerror(errno));3182 cs_exit(1);3183 }3184 3185 3220 write_versionfile(); 3186 3221 server_pid = getpid(); … … 3248 3283 3249 3284 //cs_close_log(); 3250 while ( 1) {3285 while (!exit_oscam) { 3251 3286 fd_set fds; 3252 3287 3253 3288 do { 3289 //timeout value for checking exit_oscam: 3290 struct timeval timeout; 3291 timeout.tv_sec = 1; 3292 timeout.tv_usec = 0; 3293 3294 //Wait for incoming data 3254 3295 FD_ZERO(&fds); 3255 3296 FD_SET(mfdr, &fds); … … 3260 3301 FD_SET(ph[i].ptab->ports[j].fd, &fds); 3261 3302 errno=0; 3262 select(gfd, &fds, 0, 0, 0); 3263 } while (errno==EINTR); 3264 3303 select(gfd, &fds, 0, 0, &timeout); 3304 } while (errno==EINTR && !exit_oscam); //if timeout accurs and exit_oscam is set, we break the loop 3305 3306 if (exit_oscam) 3307 break; 3308 3265 3309 first_client->last=time((time_t *)0); 3266 3310 … … 3279 3323 } 3280 3324 3325 //can't kill? running endless... 3326 //struct s_client *cl; 3327 //for (cl=first_client->next;cl;cl=cl->next) 3328 // kill_thread(cl); 3329 3281 3330 #ifdef AZBOX 3282 3331 if (openxcas_close() < 0) { … … 3285 3334 #endif 3286 3335 3287 cs_exit(1); 3288 } 3336 cs_exit(exit_oscam); 3337 return exit_oscam; 3338 } 3339 3340 #ifdef WEBIF 3341 void cs_exit_oscam() 3342 { 3343 exit_oscam=1; 3344 cs_log("exit oscam requested"); 3345 } 3346 3347 void cs_restart_oscam() 3348 { 3349 exit_oscam=99; 3350 cs_log("restart oscam requested"); 3351 } 3352 #endif 3289 3353 3290 3354 #ifdef CS_LED
Note:
See TracChangeset
for help on using the changeset viewer.