/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <errno.h>
#include "byteq.h"
-#include "dynamic-string.h"
+#include "openvswitch/dynamic-string.h"
#include "fatal-signal.h"
-#include "json.h"
-#include "list.h"
-#include "ofpbuf.h"
+#include "openvswitch/json.h"
+#include "openvswitch/list.h"
+#include "openvswitch/ofpbuf.h"
#include "ovs-thread.h"
#include "poll-loop.h"
#include "reconnect.h"
rpc->name = xstrdup(stream_get_name(stream));
rpc->stream = stream;
byteq_init(&rpc->input, rpc->input_buffer, sizeof rpc->input_buffer);
- list_init(&rpc->output);
+ ovs_list_init(&rpc->output);
return rpc;
}
}
stream_run(rpc->stream);
- while (!list_is_empty(&rpc->output)) {
+ while (!ovs_list_is_empty(&rpc->output)) {
struct ofpbuf *buf = ofpbuf_from_list(rpc->output.next);
int retval;
rpc->backlog -= retval;
ofpbuf_pull(buf, retval);
if (!buf->size) {
- list_remove(&buf->list_node);
+ ovs_list_remove(&buf->list_node);
rpc->output_count--;
ofpbuf_delete(buf);
}
{
if (!rpc->status) {
stream_run_wait(rpc->stream);
- if (!list_is_empty(&rpc->output)) {
+ if (!ovs_list_is_empty(&rpc->output)) {
stream_send_wait(rpc->stream);
}
}
struct json *json;
struct ds ds = DS_EMPTY_INITIALIZER;
size_t length;
- char *s;
if (rpc->status) {
jsonrpc_msg_destroy(msg);
json = jsonrpc_msg_to_json(msg);
json_to_ds(json, 0, &ds);
length = ds.length;
- s = ds_steal_cstr(&ds);
json_destroy(json);
buf = xmalloc(sizeof *buf);
- ofpbuf_use(buf, s, length);
- buf->size = length;
- list_push_back(&rpc->output, &buf->list_node);
+ ofpbuf_use_ds(buf, &ds);
+ ovs_list_push_back(&rpc->output, &buf->list_node);
rpc->output_count++;
rpc->backlog += length;
const struct byteq *q = &rpc->input;
if (q->head <= q->size) {
stream_report_content(q->buffer, q->head, STREAM_JSONRPC,
- THIS_MODULE, rpc->name);
+ &this_module, rpc->name);
}
return rpc->status;
}
for (;;) {
jsonrpc_run(rpc);
- if (list_is_empty(&rpc->output) || rpc->status) {
+ if (ovs_list_is_empty(&rpc->output) || rpc->status) {
return rpc->status;
}
jsonrpc_wait(rpc);
{
struct jsonrpc_msg *msg = xmalloc(sizeof *msg);
msg->type = type;
- msg->method = method ? xstrdup(method) : NULL;
+ msg->method = nullable_xstrdup(method);
msg->params = params;
msg->result = result;
msg->error = error;