[patch] SIGUSR1 increments max_send on fakesmsc
Rudy Matela <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <CALCD0B-9r3gUQjjRusCiakMwQyQONUTs+wWVev678jBf-d=A_A@mail.gmail.com> |
Hello, Don't know if this patch is elegible for the trunk of kannel. But it was useful for me. I wanted a way to keep sending random messages using fakesmsc even when the limit was hit: I've patched it to treat the SIGUSR1 signal as a increment command to the max_send variable. This way you can do: $ ./test/fakesmsc -m 0 "100 200 text blah" 2012-09-11 13:22:17 [21787] [0] INFO: Debug_lvl = -1, log_file = <none>, log_lvl = 0 2012-09-11 13:22:17 [21787] [0] INFO: Host localhost Port 10000 interval 1.000 max-messages 0 2012-09-11 13:22:17 [21787] [0] INFO: fakesmsc starting 2012-09-11 13:22:17 [21787] [0] DEBUG: Connecting to <127.0.0.1> An on other terminal: $ kill -s SIGUSR1 21787 Then on the terminal with fakesmsc appears: 2012-09-11 13:22:26 [21787] [0] INFO: fakesmsc: sent message 1 And you can tell fakesmsc to send random messages when you want and not on a fixed interval. In other words, This patch makes fakesmsc interpret the SIGUSR1 signal as a command to send another message after the cap is hit. Regards, Rudy
fakesmsc-sigusr1-increments-max_send.patch
(application/octet-stream, 534 B)
Index: test/fakesmsc.c
===================================================================
--- test/fakesmsc.c (revision 4995)
+++ test/fakesmsc.c (working copy)
@@ -128,6 +128,9 @@
{
if (signum == SIGINT)
sigint_received = 1;
+ if (signum == SIGUSR1)
+ if (max_send < LONG_MAX)
+ max_send ++;
else
panic(0, "Caught signal with no handler?!");
}
@@ -141,6 +144,7 @@
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
sigaction(SIGINT, &act, NULL);
+ sigaction(SIGUSR1, &act, NULL);
}