Changeset 10694
- Timestamp:
- 06/09/15 23:11:51 (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-gbox-sms.c
r10378 r10694 289 289 } 290 290 } 291 292 static pthread_t sms_sender_thread; 293 static int32_t sms_sender_active = 0; 294 static pthread_cond_t sleep_cond; 295 static pthread_mutex_t sleep_cond_mutex; 296 static pthread_mutex_t sms_mutex = PTHREAD_MUTEX_INITIALIZER; 297 298 static void sms_sender(void) 299 { 300 char *fext= FILE_GSMS_TXT; 301 char *fname = get_gbox_tmp_fname(fext); 302 303 while(sms_sender_active) 304 { 305 if (file_exists(fname)) 306 { 307 gbox_init_send_gsms(); 308 } 309 310 sleepms_on_cond(&sleep_cond_mutex, &sleep_cond, 1000); 311 } 312 pthread_exit(NULL); 313 } 314 315 void start_sms_sender(void) 316 { 317 int32_t is_active; 318 319 pthread_mutex_lock(&sms_mutex); 320 is_active = sms_sender_active; 321 if(!sms_sender_active) 322 { 323 sms_sender_active = 1; 324 } 325 pthread_mutex_unlock(&sms_mutex); 326 327 if(is_active) 328 { 329 return; 330 } 331 332 cs_pthread_cond_init(&sleep_cond_mutex, &sleep_cond); 333 334 pthread_attr_t attr; 335 pthread_attr_init(&attr); 336 337 pthread_attr_setstacksize(&attr, PTHREAD_STACK_SIZE); 338 int32_t ret = pthread_create(&sms_sender_thread, &attr, (void *)&sms_sender, NULL); 339 if(ret) 340 { 341 cs_log("ERROR: can't create sms_sender_thread thread (errno=%d %s)", ret, strerror(ret)); 342 pthread_attr_destroy(&attr); 343 cs_exit(1); 344 } 345 pthread_attr_destroy(&attr); 346 } 347 348 void stop_sms_sender(void) 349 { 350 pthread_mutex_lock(&sms_mutex); 351 352 if(sms_sender_active) 353 { 354 sms_sender_active = 0; 355 pthread_cond_signal(&sleep_cond); 356 pthread_join(sms_sender_thread, NULL); 357 } 358 359 pthread_mutex_unlock(&sms_mutex); 360 } 361 362 291 363 #endif -
trunk/module-gbox-sms.h
r9757 r10694 15 15 void write_gsms_ack (struct s_client *cli, uint8_t gsms_prot); 16 16 void gsms_unavail(void); 17 void start_sms_sender(void); 18 void stop_sms_sender(void); 19 17 20 #endif 18 21 -
trunk/module-gbox.c
r10650 r10694 478 478 cl->gbox_peer_id = NO_GBOX_ID; 479 479 cl->init_done = 1; 480 481 start_sms_sender(); 480 482 } 481 483 return; … … 1598 1600 { cli->reader->gbox_cccam_reshare = DEFAULT_GBOX_RESHARE; } 1599 1601 1602 start_sms_sender(); 1603 1600 1604 return 0; 1601 1605 } -
trunk/oscam.c
r10689 r10694 16 16 #include "module-dvbapi-mca.h" 17 17 #include "module-dvbapi-chancache.h" 18 #include "module-gbox-sms.h" 18 19 #include "module-ird-guess.h" 19 20 #include "module-lcd.h" … … 1680 1681 1681 1682 // Cleanup 1683 stop_sms_sender(); 1682 1684 webif_close(); 1683 1685 azbox_close();
Note:
See TracChangeset
for help on using the changeset viewer.