aboutsummaryrefslogtreecommitdiff
path: root/lib/jsonrpc.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-04-13 09:28:13 -0700
committerBen Pfaff <blp@nicira.com>2010-04-13 09:30:32 -0700
commitb302749b70bd8b487bdfe0ffcdacbf730da8b6ca (patch)
treedc528b241a3bbe9d9b8fab762c614af4ae55bc36 /lib/jsonrpc.c
parent9888b1b43ba258e7842100799406f57392c76db7 (diff)
Make fatal signals cause an exit more promptly in special cases.
The fatal-signal library notices and records fatal signals (e.g. SIGTERM) and terminates the process on the next trip through poll_block(). But some special utilities do not always invoke poll_block() promptly, e.g. "ovs-ofctl monitor" does not call poll_block() as long as OpenFlow messages are available. But these special cases seem like they are all likely to call into functions that themselves block (those with "_block" in their names). So make a new rule that such functions should always call fatal_signal_run(), either directly or through poll_block(). This commit implements and documents that rule. Bug #2625.
Diffstat (limited to 'lib/jsonrpc.c')
-rw-r--r--lib/jsonrpc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index 72590a2f..828bdac2 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -23,6 +23,7 @@
#include "byteq.h"
#include "dynamic-string.h"
+#include "fatal-signal.h"
#include "json.h"
#include "list.h"
#include "ofpbuf.h"
@@ -293,6 +294,8 @@ jsonrpc_send_block(struct jsonrpc *rpc, struct jsonrpc_msg *msg)
{
int error;
+ fatal_signal_run();
+
error = jsonrpc_send(rpc, msg);
if (error) {
return error;
@@ -314,6 +317,7 @@ jsonrpc_recv_block(struct jsonrpc *rpc, struct jsonrpc_msg **msgp)
for (;;) {
int error = jsonrpc_recv(rpc, msgp);
if (error != EAGAIN) {
+ fatal_signal_run();
return error;
}