projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
netflow: Back-out optimization that could lead to infinite loop
[openvswitch]
/
lib
/
jsonrpc.c
diff --git
a/lib/jsonrpc.c
b/lib/jsonrpc.c
index 72590a2f41da2d73c1b1c35da361e89a54cc8590..22579e0a67e57e6e5c3024bad5cb1d2f6da6efba 100644
(file)
--- a/
lib/jsonrpc.c
+++ b/
lib/jsonrpc.c
@@
-23,6
+23,7
@@
#include "byteq.h"
#include "dynamic-string.h"
#include "byteq.h"
#include "dynamic-string.h"
+#include "fatal-signal.h"
#include "json.h"
#include "list.h"
#include "ofpbuf.h"
#include "json.h"
#include "list.h"
#include "ofpbuf.h"
@@
-31,9
+32,9
@@
#include "reconnect.h"
#include "stream.h"
#include "timeval.h"
#include "reconnect.h"
#include "stream.h"
#include "timeval.h"
-
-#define THIS_MODULE VLM_jsonrpc
#include "vlog.h"
#include "vlog.h"
+
+VLOG_DEFINE_THIS_MODULE(jsonrpc)
\f
struct jsonrpc {
struct stream *stream;
\f
struct jsonrpc {
struct stream *stream;
@@
-248,7
+249,6
@@
jsonrpc_recv(struct jsonrpc *rpc, struct jsonrpc_msg **msgp)
return rpc->status;
}
} else if (retval == 0) {
return rpc->status;
}
} else if (retval == 0) {
- VLOG_INFO_RL(&rl, "%s: connection closed", rpc->name);
jsonrpc_error(rpc, EOF);
return EOF;
}
jsonrpc_error(rpc, EOF);
return EOF;
}
@@
-266,6
+266,12
@@
jsonrpc_recv(struct jsonrpc *rpc, struct jsonrpc_msg **msgp)
if (json_parser_is_done(rpc->parser)) {
jsonrpc_received(rpc);
if (rpc->status) {
if (json_parser_is_done(rpc->parser)) {
jsonrpc_received(rpc);
if (rpc->status) {
+ const struct byteq *q = &rpc->input;
+ if (q->head <= BYTEQ_SIZE) {
+ stream_report_content(q->buffer, q->head,
+ STREAM_JSONRPC,
+ THIS_MODULE, rpc->name);
+ }
return rpc->status;
}
}
return rpc->status;
}
}
@@
-293,6
+299,8
@@
jsonrpc_send_block(struct jsonrpc *rpc, struct jsonrpc_msg *msg)
{
int error;
{
int error;
+ fatal_signal_run();
+
error = jsonrpc_send(rpc, msg);
if (error) {
return error;
error = jsonrpc_send(rpc, msg);
if (error) {
return error;
@@
-314,6
+322,7
@@
jsonrpc_recv_block(struct jsonrpc *rpc, struct jsonrpc_msg **msgp)
for (;;) {
int error = jsonrpc_recv(rpc, msgp);
if (error != EAGAIN) {
for (;;) {
int error = jsonrpc_recv(rpc, msgp);
if (error != EAGAIN) {
+ fatal_signal_run();
return error;
}
return error;
}
@@
-691,7
+700,10
@@
jsonrpc_session_open(const char *name)
}
/* Creates and returns a jsonrpc_session that is initially connected to
}
/* Creates and returns a jsonrpc_session that is initially connected to
- * 'jsonrpc'. If the connection is dropped, it will not be reconnected. */
+ * 'jsonrpc'. If the connection is dropped, it will not be reconnected.
+ *
+ * On the assumption that such connections are likely to be short-lived
+ * (e.g. from ovs-vsctl), informational logging for them is suppressed. */
struct jsonrpc_session *
jsonrpc_session_open_unreliably(struct jsonrpc *jsonrpc)
{
struct jsonrpc_session *
jsonrpc_session_open_unreliably(struct jsonrpc *jsonrpc)
{
@@
-699,6
+711,7
@@
jsonrpc_session_open_unreliably(struct jsonrpc *jsonrpc)
s = xmalloc(sizeof *s);
s->reconnect = reconnect_create(time_msec());
s = xmalloc(sizeof *s);
s->reconnect = reconnect_create(time_msec());
+ reconnect_set_quiet(s->reconnect, true);
reconnect_set_name(s->reconnect, jsonrpc_get_name(jsonrpc));
reconnect_set_max_tries(s->reconnect, 0);
reconnect_connected(s->reconnect, time_msec());
reconnect_set_name(s->reconnect, jsonrpc_get_name(jsonrpc));
reconnect_set_max_tries(s->reconnect, 0);
reconnect_connected(s->reconnect, time_msec());
@@
-792,7
+805,7
@@
jsonrpc_session_run(struct jsonrpc_session *s)
jsonrpc_run(s->rpc);
error = jsonrpc_get_status(s->rpc);
if (error) {
jsonrpc_run(s->rpc);
error = jsonrpc_get_status(s->rpc);
if (error) {
- reconnect_disconnected(s->reconnect, time_msec(),
0
);
+ reconnect_disconnected(s->reconnect, time_msec(),
error
);
jsonrpc_session_disconnect(s);
}
} else if (s->stream) {
jsonrpc_session_disconnect(s);
}
} else if (s->stream) {
@@
-890,8
+903,8
@@
jsonrpc_session_recv(struct jsonrpc_session *s)
reply = jsonrpc_create_reply(json_clone(msg->params), msg->id);
jsonrpc_session_send(s, reply);
} else if (msg->type == JSONRPC_REPLY
reply = jsonrpc_create_reply(json_clone(msg->params), msg->id);
jsonrpc_session_send(s, reply);
} else if (msg->type == JSONRPC_REPLY
- && msg->id && msg->id->type == JSON_STRING
- && !strcmp(msg->id->u.string, "echo")) {
+
&& msg->id && msg->id->type == JSON_STRING
+
&& !strcmp(msg->id->u.string, "echo")) {
/* It's a reply to our echo request. Suppress it. */
} else {
return msg;
/* It's a reply to our echo request. Suppress it. */
} else {
return msg;