Browse Source

Add --notify-wait (-9) option (not set by default).

Using it prevents running of several notification scripts in parallel
which can lead to races if the scripts are used for logging.
Georgi Chorbadzhiyski 7 years ago
parent
commit
28dd637542
6 changed files with 29 additions and 3 deletions
  1. 3
    0
      ChangeLog
  2. 2
    0
      README
  3. 1
    0
      data.h
  4. 2
    0
      notify.c
  5. 13
    0
      tsdecrypt.1
  6. 8
    3
      tsdecrypt.c

+ 3
- 0
ChangeLog View File

1
 xxxx-xx-xx : Version -next
1
 xxxx-xx-xx : Version -next
2
  * Add new notification message STREAM_NOT_ENCRYPTED. When stream is not
2
  * Add new notification message STREAM_NOT_ENCRYPTED. When stream is not
3
    encrypted no NO_CODE_WORD notifications are sent.
3
    encrypted no NO_CODE_WORD notifications are sent.
4
+ * Add --notify-wait (-9) option (not set by default). Using it prevents
5
+   running of several notification scripts in parallel which can lead to
6
+   races if the scripts are used for logging.
4
 
7
 
5
 2013-09-12 : Version 10.0
8
 2013-09-12 : Version 10.0
6
  * Add --ecm-only (-v) option. This allows processing of ECMs but without
9
  * Add --ecm-only (-v) option. This allows processing of ECMs but without

+ 2
- 0
README View File

102
  -i --ident <server>        | Format PROVIDER/CHANNEL. Default: empty
102
  -i --ident <server>        | Format PROVIDER/CHANNEL. Default: empty
103
  -d --daemon <pidfile>      | Daemonize program and write pid file.
103
  -d --daemon <pidfile>      | Daemonize program and write pid file.
104
  -N --notify-program <prg>  | Execute <prg> to report events. Default: empty
104
  -N --notify-program <prg>  | Execute <prg> to report events. Default: empty
105
+ -9 --notify-wait           | Enable one by one notification delivery.
106
+                            . Default: not set (async, deliver ASAP)
105
 
107
 
106
 Input options:
108
 Input options:
107
  -I --input <source>        | Where to read from. File or multicast address.
109
  -I --input <source>        | Where to read from. File or multicast address.

+ 1
- 0
data.h View File

359
 
359
 
360
 	struct notify		*notify;
360
 	struct notify		*notify;
361
 	char				*notify_program;
361
 	char				*notify_program;
362
+	int					notify_wait;
362
 
363
 
363
 	unsigned int		input_buffer_time;
364
 	unsigned int		input_buffer_time;
364
 	LIST				*input_buffer;
365
 	LIST				*input_buffer;

+ 2
- 0
notify.c View File

143
 	np = calloc(1, sizeof(struct npriv));
143
 	np = calloc(1, sizeof(struct npriv));
144
 
144
 
145
 	np->sync = sync_msg;
145
 	np->sync = sync_msg;
146
+	if (ts->notify_wait)
147
+		np->sync = 1;
146
 	npriv_init_defaults(ts->notify, np);
148
 	npriv_init_defaults(ts->notify, np);
147
 
149
 
148
 	strncpy(np->msg_id, msg_id, sizeof(np->ident) - 1);
150
 	strncpy(np->msg_id, msg_id, sizeof(np->ident) - 1);

+ 13
- 0
tsdecrypt.1 View File

30
 
30
 
31
 See \fBEVENTS\fR section for detailed description of the events.
31
 See \fBEVENTS\fR section for detailed description of the events.
32
 .TP
32
 .TP
33
+\fB\-9\fR, \fB\-\-notify-wait\fR
34
+Wait for notification script to exit before starting another notification.
35
+
36
+By default notifications script is executed as soon as notification is
37
+received. But since several notifications might come at one time, there
38
+is no guarantee that notification script would be run sequentially. The
39
+notification script for newer notification might be run before an older
40
+notification.
41
+
42
+Setting this option makes sure that you'll have only one notify script
43
+running. \fB*NOTE*\fR if you set this option make sure that notification
44
+script does not take a lot of time to run or you'll run into problems.
45
+.TP
33
 \fB\-S\fR, \fB\-\-syslog\fR
46
 \fB\-S\fR, \fB\-\-syslog\fR
34
 Write log messages to local syslog.
47
 Write log messages to local syslog.
35
 .TP
48
 .TP

+ 8
- 3
tsdecrypt.c View File

77
 		LOG(msg);
77
 		LOG(msg);
78
 }
78
 }
79
 
79
 
80
-static const char short_options[] = "i:d:N:Sl:L:F:I:1:RzM:T:W:O:o:t:rk:g:upwxyc:C:Y:Q:A:s:U:P:B:46eZ:Ef:a:X:vqH:G:2:KJ:D:jbhVn:m:";
80
+static const char short_options[] = "i:d:N:9Sl:L:F:I:1:RzM:T:W:O:o:t:rk:g:upwxyc:C:Y:Q:A:s:U:P:B:46eZ:Ef:a:X:vqH:G:2:KJ:D:jbhVn:m:";
81
 
81
 
82
 // Unused short options: 035789
82
 // Unused short options: 035789
83
 static const struct option long_options[] = {
83
 static const struct option long_options[] = {
88
 	{ "syslog-port",		required_argument, NULL, 'L' },
88
 	{ "syslog-port",		required_argument, NULL, 'L' },
89
 	{ "log-file",			required_argument, NULL, 'F' },
89
 	{ "log-file",			required_argument, NULL, 'F' },
90
 	{ "notify-program",		required_argument, NULL, 'N' },
90
 	{ "notify-program",		required_argument, NULL, 'N' },
91
+	{ "notify-wait",		no_argument,       NULL, '9' },
91
 
92
 
92
 	{ "input",				required_argument, NULL, 'I' },
93
 	{ "input",				required_argument, NULL, 'I' },
93
 	{ "input-source",		required_argument, NULL, '1' },
94
 	{ "input-source",		required_argument, NULL, '1' },
160
 	printf(" -i --ident <server>        | Format PROVIDER/CHANNEL. Default: empty\n");
161
 	printf(" -i --ident <server>        | Format PROVIDER/CHANNEL. Default: empty\n");
161
 	printf(" -d --daemon <pidfile>      | Daemonize program and write pid file.\n");
162
 	printf(" -d --daemon <pidfile>      | Daemonize program and write pid file.\n");
162
 	printf(" -N --notify-program <prg>  | Execute <prg> to report events. Default: empty\n");
163
 	printf(" -N --notify-program <prg>  | Execute <prg> to report events. Default: empty\n");
164
+	printf(" -9 --notify-wait           | Enable one by one notification delivery.\n");
165
+	printf("                            . Default: not set (async, deliver ASAP)\n");
163
 	printf("\n");
166
 	printf("\n");
164
 	printf("Input options:\n");
167
 	printf("Input options:\n");
165
 	printf(" -I --input <source>        | Where to read from. File or multicast address.\n");
168
 	printf(" -I --input <source>        | Where to read from. File or multicast address.\n");
314
 			case 'N': // --notify-program
317
 			case 'N': // --notify-program
315
 				ts->notify_program = optarg;
318
 				ts->notify_program = optarg;
316
 				break;
319
 				break;
317
-
320
+			case '9': // --notify-wait
321
+				ts->notify_wait = !ts->notify_wait;
322
+				break;
318
 			case 'S': // --syslog
323
 			case 'S': // --syslog
319
 				ts->syslog_active = 1;
324
 				ts->syslog_active = 1;
320
 				ts->syslog_remote = 0;
325
 				ts->syslog_remote = 0;
682
 	if (ts->ident)
687
 	if (ts->ident)
683
 		ts_LOGf("Ident      : %s\n", ts->ident);
688
 		ts_LOGf("Ident      : %s\n", ts->ident);
684
 	if (ts->notify_program)
689
 	if (ts->notify_program)
685
-		ts_LOGf("Notify prg : %s\n", ts->notify_program);
690
+		ts_LOGf("Notify prg : %s (%s)\n", ts->notify_program, ts->notify_wait ? "sync" : "async");
686
 	if (ts->pidfile)
691
 	if (ts->pidfile)
687
 		ts_LOGf("Daemonize  : %s pid file.\n", ts->pidfile);
692
 		ts_LOGf("Daemonize  : %s pid file.\n", ts->pidfile);
688
 	if (ts->syslog_active) {
693
 	if (ts->syslog_active) {

Loading…
Cancel
Save