int
jsonrpc_recv(struct jsonrpc *rpc, struct jsonrpc_msg **msgp)
{
+ int i;
+
*msgp = NULL;
if (rpc->status) {
return rpc->status;
}
- while (!rpc->received) {
- if (byteq_is_empty(&rpc->input)) {
+ for (i = 0; i < 50; i++) {
+ if (rpc->received) {
+ *msgp = rpc->received;
+ rpc->received = NULL;
+ return 0;
+ } else if (byteq_is_empty(&rpc->input)) {
size_t chunk;
int retval;
}
}
- *msgp = rpc->received;
- rpc->received = NULL;
- return 0;
+ return EAGAIN;
}
/* Causes the poll loop to wake up when jsonrpc_recv() may return a value other
struct stream *stream;
struct pstream *pstream;
unsigned int seqno;
+ uint8_t dscp;
};
/* Creates and returns a jsonrpc_session to 'name', which should be a string
s->stream = NULL;
s->pstream = NULL;
s->seqno = 0;
+ s->dscp = 0;
if (!pstream_verify_name(name)) {
reconnect_set_passive(s->reconnect, true, time_msec());
jsonrpc_session_disconnect(s);
if (!reconnect_is_passive(s->reconnect)) {
- error = jsonrpc_stream_open(name, &s->stream,
- reconnect_get_dscp(s->reconnect));
+ error = jsonrpc_stream_open(name, &s->stream, s->dscp);
if (!error) {
reconnect_connecting(s->reconnect, time_msec());
}
} else {
error = s->pstream ? 0 : jsonrpc_pstream_open(name, &s->pstream,
- reconnect_get_dscp(s->reconnect));
+ s->dscp);
if (!error) {
reconnect_listening(s->reconnect, time_msec());
}
jsonrpc_session_set_dscp(struct jsonrpc_session *s,
uint8_t dscp)
{
- reconnect_set_dscp(s->reconnect, dscp);
+ s->dscp = dscp;
}