Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents aa460a3 + 1f31861 commit 5b5883036297995d74430c6bdc3ca68a829c80c5 @vortechs2000 committed Nov 9, 2011
Showing with 50 additions and 61 deletions.
  1. +2 −0 AUTHORS
  2. +2 −2 configure.in
  3. +2 −0 sockopts.gsl
  4. +2 −1 src/zclock.c
  5. +0 −1 src/zctx.c
  6. +0 −1 src/zframe.c
  7. +0 −1 src/zhash.c
  8. +2 −2 src/zlist.c
  9. +5 −5 src/zloop.c
  10. +31 −41 src/zmsg.c
  11. +0 −1 src/zsockopt.c
  12. +3 −2 src/zstr.c
  13. +1 −4 src/zthread.c
View
@@ -9,3 +9,5 @@ Contributors
Steven McCoy <steven.mccoy@miru.hk>
Luc Heinrich <luc@honk-honk.com>
William Roberts <bill.c.roberts@gmail.com>
+AJ Lewis <aj.lewis@quantum.com>
+
View
@@ -29,12 +29,12 @@ AC_SUBST(PACKAGE_VERSION)
#
# Libtool -version-info (ABI version)
#
-# Currently 0.0.0 ("unstable"). Don't change this unless you
+# Currently 1.0.0 ("stable"). Don't change this unless you
# know exactly what you're doing and have read and understand
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
#
# libczmq -version-info
-LTVER="0:0:0"
+LTVER="1:0:0"
AC_SUBST(LTVER)
# Capture c flags
View
@@ -201,11 +201,13 @@ zsockopt_test (Bool verbose)
// @selftest
zctx_t *ctx = zctx_new ();
+ assert (ctx);
void *socket;
.for version
#if (ZMQ_VERSION_MAJOR == $(major))
. for option
socket = zsocket_new (ctx, ZMQ_$(TEST));
+ assert (socket);
. if mode = "rw" | mode = "w"
. if ctype = "int"
zsockopt_set_$(name) (socket, 1);
View
@@ -95,7 +95,8 @@ zclock_time (void)
#if defined (__UNIX__)
struct timeval tv;
gettimeofday (&tv, NULL);
- return (int64_t) (tv.tv_sec * 1000 + tv.tv_usec / 1000);
+
+ return (int64_t) ((int64_t) tv.tv_sec * 1000 + (int64_t) tv.tv_usec / 1000);
#elif (defined (__WINDOWS__))
FILETIME ft;
GetSystemTimeAsFileTime (&ft);
View
@@ -119,7 +119,6 @@ zctx_new (void)
#endif
end:
-
return self;
}
View
@@ -187,7 +187,6 @@ zframe_send (zframe_t **self_p, void *socket, int flags)
error = EINVAL;
end:
-
return error;
}
View
@@ -288,7 +288,6 @@ zhash_insert (zhash_t *self, char *key, void *value)
if ((!error) && (!item))
error = -1;
}
-
return error;
}
View
@@ -243,12 +243,12 @@ zlist_copy (zlist_t *self)
goto end;
struct node_t *node;
- for (node = self->head; node; node = node->next)
+ for (node = self->head; node; node = node->next) {
if (!zlist_append (copy, node->item)) {
zlist_destroy(&copy);
break;
}
-
+ }
end:
return copy;
}
View
@@ -123,14 +123,14 @@ s_rebuild_pollset (zloop_t *self)
self->poll_size = zlist_size (self->pollers);
self->pollset = (zmq_pollitem_t *) zmalloc (
self->poll_size * sizeof (zmq_pollitem_t));
- if (!(self->pollset)) {
+ if (!self->pollset) {
error = ENOMEM;
goto end;
}
self->pollact = (s_poller_t *) zmalloc (
self->poll_size * sizeof (s_poller_t));
- if (!(self->pollact)) {
+ if (!self->pollact) {
error = ENOMEM;
goto end;
}
@@ -194,17 +194,17 @@ zloop_new (void)
goto end;
self->pollers = zlist_new ();
- if (!(self->pollers)) {
+ if (!self->pollers) {
error = ENOMEM;
goto end;
}
self->timers = zlist_new ();
- if (!(self->timers)) {
+ if (!self->timers) {
error = ENOMEM;
goto end;
}
self->zombies = zlist_new ();
- if (!(self->zombies)) {
+ if (!self->zombies) {
error = ENOMEM;
goto end;
}
View
@@ -60,15 +60,14 @@ zmsg_new (void)
self = (zmsg_t *) zmalloc (sizeof (zmsg_t));
if (!self)
- goto end;
+ goto end;
self->frames = zlist_new ();
if (!(self->frames)) {
- free (self);
- self = NULL;
- goto end;
+ free (self);
+ self = NULL;
+ goto end;
}
-
end:
return self;
}
@@ -113,13 +112,12 @@ zmsg_recv (void *socket)
break; // Interrupted or terminated
}
if (zmsg_add (self, frame)) {
- zmsg_destroy (&self);
- break;
- }
+ zmsg_destroy (&self);
+ break;
+ }
if (!zframe_more (frame))
break; // Last message frame
}
-
end:
return self;
}
@@ -261,13 +259,17 @@ zmsg_addmem (zmsg_t *self, const void *src, size_t size)
return error;
}
-// --------------------------------------------------------------------------
-// Handle the mechanics of pushing the string frame into the list - the list
-// function passed in determines how the frame containing the string
-// enters the list
-int zmsg_add_str_to_framelist (int (*list_fxn)(zlist_t *, void *),
- zmsg_t *self, const char *format, va_list argptr)
+// --------------------------------------------------------------------------
+// Handle the mechanics of pushing the string frame into the list - the list
+// function passed in determines how the frame containing the string
+// enters the list
+
+static int zmsg_add_str_to_framelist (
+ int (*list_fxn) (zlist_t *, void *),
+ zmsg_t *self,
+ const char *format,
+ va_list argptr)
{
assert (list_fxn);
assert (self);
@@ -279,7 +281,6 @@ int zmsg_add_str_to_framelist (int (*list_fxn)(zlist_t *, void *),
error = ENOMEM;
goto end;
}
-
int required = vsnprintf (string, size, format, argptr);
if (required >= size) {
char *tmpstring;
@@ -292,14 +293,12 @@ int zmsg_add_str_to_framelist (int (*list_fxn)(zlist_t *, void *),
string = tmpstring;
vsnprintf (string, size, format, argptr);
}
-
self->content_size += strlen (string);
zframe_t *frame = zframe_new (string, strlen (string));
if (!frame) {
error = ENOMEM;
goto end;
}
-
error = list_fxn (self->frames, frame);
end:
@@ -312,13 +311,13 @@ int zmsg_add_str_to_framelist (int (*list_fxn)(zlist_t *, void *),
// --------------------------------------------------------------------------
// Push string as new frame to front of message
-int zmsg_pushstr(zmsg_t *self, const char *format, ...)
+int zmsg_pushstr (zmsg_t *self, const char *format, ...)
{
assert (format);
va_list argptr;
va_start (argptr, format);
- int error = zmsg_add_str_to_framelist(&zlist_push, self, format, argptr);
+ int error = zmsg_add_str_to_framelist (&zlist_push, self, format, argptr);
va_end (argptr);
return error;
@@ -336,7 +335,6 @@ zmsg_addstr (zmsg_t *self, const char *format, ...)
va_start (argptr, format);
int error = zmsg_add_str_to_framelist (&zlist_append, self, format, argptr);
-
va_end (argptr);
return error;
@@ -373,15 +371,14 @@ zmsg_wrap (zmsg_t *self, zframe_t *frame)
int error = 0;
error = zmsg_pushmem (self, "", 0);
if (error)
- goto end;
+ goto end;
error = zmsg_push (self, frame);
if (error) {
- // Rewind the empty frame
- zmsg_pop (self);
- goto end;
+ // Rewind the empty frame
+ zmsg_pop (self);
+ goto end;
}
-
end:
return error;
}
@@ -481,10 +478,10 @@ zmsg_save (zmsg_t *self, FILE *file)
// --------------------------------------------------------------------------
// Load/append an open file into message, create new message if
-// null message provided. Return 0 if OK, non-zero otherwise. The
+// null message provided. Return 0 if OK, non-zero otherwise. The
// returned message should be identical to the passed in message on
// error.
-//
+//
int
zmsg_load (zmsg_t *self, FILE *file, zmsg_t **return_self)
@@ -526,11 +523,9 @@ zmsg_load (zmsg_t *self, FILE *file, zmsg_t **return_self)
goto end;
}
}
-
error = zmsg_add (tmp_msg, frame);
- if (error)
- goto end;
-
+ if (error)
+ goto end;
frame_count++;
}
else {
@@ -541,9 +536,8 @@ zmsg_load (zmsg_t *self, FILE *file, zmsg_t **return_self)
else {
if (feof (file))
goto end;
-
error = ferror (file);
- if (!error)
+ if (!error)
error = 1;
goto end; // Unable to read properly, quit
}
@@ -566,9 +560,7 @@ zmsg_load (zmsg_t *self, FILE *file, zmsg_t **return_self)
zmsg_destroy (&tmp_msg);
}
}
-
*return_self = tmp_msg;
-
return error;
}
@@ -681,10 +673,9 @@ zmsg_decode (byte *buffer, size_t buffer_size)
zframe_t *frame = zframe_new (source, frame_size);
if (frame) {
if (zmsg_add (self, frame)) {
- zmsg_destroy (&self);
- break;
- }
-
+ zmsg_destroy (&self);
+ break;
+ }
source += frame_size;
}
else {
@@ -727,7 +718,6 @@ zmsg_dup (zmsg_t *self)
}
end:
-
return copy;
}
View
@@ -1226,7 +1226,6 @@ zsockopt_test (Bool verbose)
// @selftest
zctx_t *ctx = zctx_new ();
assert (ctx);
-
void *socket;
#if (ZMQ_VERSION_MAJOR == 2)
socket = zsocket_new (ctx, ZMQ_SUB);
View
@@ -64,8 +64,9 @@ zstr_recv (void *socket)
// --------------------------------------------------------------------------
// Receive C string from socket, if socket had input ready. Caller must
-// free returned string. Returns NULL if the context is being terminated
-// or the process was interrupted.
+// free returned string. Returns NULL if there was no input waiting, or if
+// the context was terminated. Use zctx_interrupted to exit any loop that
+// relies on this method.
char *
zstr_recv_nowait (void *socket)
View
@@ -94,6 +94,7 @@ s_thread_shim (void *args)
shim->attached (shim->args, shim->ctx, shim->pipe);
else
shim->detached (shim->args);
+
zctx_destroy (&shim->ctx);
free (shim);
return NULL;
@@ -187,7 +188,6 @@ zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args)
error = ENOMEM;
goto end;
}
-
zsockopt_set_hwm (pipe, 1);
zsocket_bind (pipe, "inproc://zctx-pipe-%p", pipe);
@@ -197,15 +197,13 @@ zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args)
error = ENOMEM;
goto end;
}
-
shim->attached = thread_fn;
shim->args = args;
shim->ctx = zctx_shadow (ctx);
if (!shim->ctx) {
error = ENOMEM;
goto end;
}
-
// Connect child pipe to our pipe
shim->pipe = zsocket_new (shim->ctx, ZMQ_PAIR);
if (!shim->pipe) {
@@ -226,7 +224,6 @@ zthread_fork (zctx_t *ctx, zthread_attached_fn *thread_fn, void *args)
}
zsocket_destroy (ctx, pipe);
}
-
return pipe;
}

0 comments on commit 5b58830

Please sign in to comment.