"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/mi_fifo/fifo_fnc.c" between
opensips-3.2.0-rc1.tar.gz and opensips-3.2.0.tar.gz

About: OpenSIPS is a multi-functional, multi-purpose signaling SIP Server (Session Initiation Protocol). It can act as SIP Router/Switch, SIP Registrar, Application Server, Redirect Server, Load Balancer / Dispatcher, Back-to-Back User Agent, Presence Server, IM Server, Session Border Controller, SIP Front-End, NAT traversal Server, IP Gateway (SMS, XMPP) and others.

fifo_fnc.c  (opensips-3.2.0-rc1):fifo_fnc.c  (opensips-3.2.0)
skipping to change at line 653 skipping to change at line 653
int read_len, parse_len; int read_len, parse_len;
char *req_method = NULL; char *req_method = NULL;
char *file_sep, *file, *p, *f; char *file_sep, *file, *p, *f;
struct mi_cmd *cmd = NULL; struct mi_cmd *cmd = NULL;
FILE *reply_stream; FILE *reply_stream;
struct mi_handler *hdl = NULL; struct mi_handler *hdl = NULL;
mi_response_t *response = NULL; mi_response_t *response = NULL;
int rc; int rc;
str buf; str buf;
reply_stream = NULL;
/* commands must look this way ':[filename]:' */ /* commands must look this way ':[filename]:' */
if (mi_read_fifo(mi_buf + remain_len, if (mi_read_fifo(mi_buf + remain_len,
MAX_MI_FIFO_BUFFER - remain_len, MAX_MI_FIFO_BUFFER - remain_len,
&fifo_stream, &read_len)) { &fifo_stream, &read_len)) {
LM_ERR("failed to read command\n"); LM_ERR("failed to read command\n");
goto skip_unparsed; goto skip_unparsed;
} }
remain_len = read_len; parse_len = remain_len + read_len;
parse_len = read_len;
retry:
p = mi_buf; p = mi_buf;
reply_stream = NULL;
while (parse_len && is_ws(*p)) { while (parse_len && is_ws(*p)) {
p++; p++;
parse_len--; parse_len--;
} }
if (parse_len==0) { if (parse_len==0) {
LM_DBG("command file is empty\n"); LM_DBG("command file is empty\n");
goto skip_unparsed; goto skip_unparsed;
} }
if (parse_len<3) { if (parse_len<3) {
LM_DBG("command must have at least 3 chars (has %d)\n", parse_len ); LM_DBG("command must have at least 3 chars (has %d)\n", parse_len );
return -1; return -1;
} }
if (*p!=MI_CMD_SEPARATOR) { if (*p!=MI_CMD_SEPARATOR) {
LM_ERR("command must begin with %c: %.*s\n", LM_ERR("command must begin with '%c': %.*s\n",
MI_CMD_SEPARATOR, parse_len, p); MI_CMD_SEPARATOR, parse_len, p);
goto skip_unparsed; goto skip_unparsed;
} }
p++; p++;
parse_len--; parse_len--;
file = p; file = p;
file_sep=memchr(p, MI_CMD_SEPARATOR , parse_len); file_sep=memchr(p, MI_CMD_SEPARATOR , parse_len);
if (file_sep==NULL) { if (file_sep==NULL) {
LM_ERR("file separator missing: %.*s\n", read_len, mi_buf); LM_DBG("file separator missing: %.*s\n", read_len, mi_buf);
goto skip_unparsed; return 0;
} }
if (file_sep - file + 1 >= parse_len) { if (file_sep - file + 1 >= parse_len) {
LM_DBG("no command specified yet: %.*s\n", read_len, mi_buf); LM_DBG("no command specified yet: %.*s\n", read_len, mi_buf);
return -1; return -1;
} }
p = file_sep + 1; p = file_sep + 1;
parse_len -= file_sep - file + 1; parse_len -= file_sep - file + 1;
if (file_sep==file) { if (file_sep==file) {
file = NULL; /* no reply expected */ file = NULL; /* no reply expected */
} else { } else {
skipping to change at line 718 skipping to change at line 718
} }
/* make the command null terminated */ /* make the command null terminated */
p[parse_len] = '\0'; p[parse_len] = '\0';
memset(&request, 0, sizeof request); memset(&request, 0, sizeof request);
if (parse_mi_request(p, &parse_end, &request) < 0) { if (parse_mi_request(p, &parse_end, &request) < 0) {
LM_ERR("cannot parse command: %.*s\n", parse_len, p); LM_ERR("cannot parse command: %.*s\n", parse_len, p);
return -1; return -1;
} }
if (parse_end)
LM_DBG("running command [%.*s]\n", (int)(parse_end - p), p);
else
LM_DBG("running command [%s]\n", p);
if (parse_end && parse_len != parse_end - p) { if (parse_end && parse_len != parse_end - p) {
parse_len -= parse_end - p; parse_len -= parse_end - p;
p = (char *)parse_end; p = (char *)parse_end;
memmove(mi_buf, p, parse_len); memmove(mi_buf, p, parse_len);
} else } else
parse_len = 0; parse_len = 0;
remain_len = parse_len; remain_len = parse_len;
req_method = mi_get_req_method(&request); req_method = mi_get_req_method(&request);
if (req_method) if (req_method)
skipping to change at line 772 skipping to change at line 777
LM_DBG("No reply for jsonrpc notification\n"); LM_DBG("No reply for jsonrpc notification\n");
} else if (rc < 0) { } else if (rc < 0) {
LM_ERR("failed to print json response\n"); LM_ERR("failed to print json response\n");
mi_throw_error(reply_stream, file, free_request, mi_throw_error(reply_stream, file, free_request,
"failed to print response"); "failed to print response");
} else } else
free_mi_response(response); free_mi_response(response);
} }
/* if there is no file specified, there is nothing to reply */ /* if there is no file specified, there is nothing to reply */
} else } else
goto skip_unparsed; goto end;
free_request: free_request:
free_async_handler(hdl); free_async_handler(hdl);
free_mi_request_parsed(&request); free_mi_request_parsed(&request);
if (reply_stream) if (reply_stream)
fclose(reply_stream); fclose(reply_stream);
end:
if (parse_len)
goto retry;
return 0; return 0;
skip_unparsed: skip_unparsed:
remain_len = 0; remain_len = 0;
return 0; return 0;
} }
void mi_fifo_server(FILE *fifo_stream) void mi_fifo_server(FILE *fifo_stream)
{ {
int fd; int fd;
 End of changes. 8 change blocks. 
8 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)