diff --git a/include/zmq.h b/include/zmq.h index ff7949e1..39378674 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -440,7 +440,7 @@ typedef struct zmq_pollitem_t ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout); /******************************************************************************/ -/* Poller polling on sockets,fd and threaf safe sockets */ +/* Poller polling on sockets,fd and thread-safe sockets */ /******************************************************************************/ #define ZMQ_HAVE_POLLER diff --git a/src/client.hpp b/src/client.hpp index d308e277..3b8fb225 100644 --- a/src/client.hpp +++ b/src/client.hpp @@ -55,7 +55,7 @@ namespace zmq protected: // Overrides of functions from socket_base_t. - void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_); + void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_); int xsend (zmq::msg_t *msg_); int xrecv (zmq::msg_t *msg_); bool xhas_in (); @@ -64,14 +64,14 @@ namespace zmq void xread_activated (zmq::pipe_t *pipe_); void xwrite_activated (zmq::pipe_t *pipe_); void xpipe_terminated (zmq::pipe_t *pipe_); - + private: // Messages are fair-queued from inbound pipes. And load-balanced to // the outbound pipes. fq_t fq; lb_t lb; - + client_t (const client_t &); const client_t &operator = (const client_t&); }; diff --git a/src/config.hpp b/src/config.hpp index b86c25f9..ec518896 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -80,8 +80,8 @@ namespace zmq // On some OSes the signaler has to be emulated using a TCP // connection. In such cases following port is used. - // If 0, it lets the OS choose a free port without requiring use of a - // global mutex. The original implementation of a Windows signaler + // If 0, it lets the OS choose a free port without requiring use of a + // global mutex. The original implementation of a Windows signaler // socket used port 5905 instead of letting the OS choose a free port. // https://github.com/zeromq/libzmq/issues/1542 signaler_port = 0 diff --git a/src/dist.cpp b/src/dist.cpp index 6c8dbe7a..8b306fa6 100644 --- a/src/dist.cpp +++ b/src/dist.cpp @@ -77,7 +77,7 @@ void zmq::dist_t::match (pipe_t *pipe_) // Mark the pipe as matching. pipes.swap (pipes.index (pipe_), matching); - matching++; + matching++; } void zmq::dist_t::reverse_match () diff --git a/src/encoder.hpp b/src/encoder.hpp index 741b72be..66a7adaa 100644 --- a/src/encoder.hpp +++ b/src/encoder.hpp @@ -74,7 +74,7 @@ namespace zmq { free (buf); } - + // The function returns a batch of binary data. The data // are filled to a supplied buffer. If no buffer is supplied (data_ // points to NULL) decoder object will provide buffer of its own. diff --git a/src/err.cpp b/src/err.cpp index 42048c02..8ca58e51 100644 --- a/src/err.cpp +++ b/src/err.cpp @@ -104,108 +104,108 @@ const char *zmq::wsa_error_no (int no_) // automatically (wsaError->HRESULT->string?). return (no_ == WSABASEERR) ? - "No Error" : + "No Error" : (no_ == WSAEINTR) ? - "Interrupted system call" : + "Interrupted system call" : (no_ == WSAEBADF) ? - "Bad file number" : + "Bad file number" : (no_ == WSAEACCES) ? - "Permission denied" : + "Permission denied" : (no_ == WSAEFAULT) ? - "Bad address" : + "Bad address" : (no_ == WSAEINVAL) ? - "Invalid argument" : + "Invalid argument" : (no_ == WSAEMFILE) ? - "Too many open files" : + "Too many open files" : (no_ == WSAEWOULDBLOCK) ? - "Operation would block" : + "Operation would block" : (no_ == WSAEINPROGRESS) ? - "Operation now in progress" : + "Operation now in progress" : (no_ == WSAEALREADY) ? - "Operation already in progress" : + "Operation already in progress" : (no_ == WSAENOTSOCK) ? - "Socket operation on non-socket" : + "Socket operation on non-socket" : (no_ == WSAEDESTADDRREQ) ? - "Destination address required" : + "Destination address required" : (no_ == WSAEMSGSIZE) ? - "Message too long" : + "Message too long" : (no_ == WSAEPROTOTYPE) ? - "Protocol wrong type for socket" : + "Protocol wrong type for socket" : (no_ == WSAENOPROTOOPT) ? - "Bad protocol option" : + "Bad protocol option" : (no_ == WSAEPROTONOSUPPORT) ? - "Protocol not supported" : + "Protocol not supported" : (no_ == WSAESOCKTNOSUPPORT) ? - "Socket type not supported" : + "Socket type not supported" : (no_ == WSAEOPNOTSUPP) ? - "Operation not supported on socket" : + "Operation not supported on socket" : (no_ == WSAEPFNOSUPPORT) ? - "Protocol family not supported" : + "Protocol family not supported" : (no_ == WSAEAFNOSUPPORT) ? - "Address family not supported by protocol family" : + "Address family not supported by protocol family" : (no_ == WSAEADDRINUSE) ? - "Address already in use" : + "Address already in use" : (no_ == WSAEADDRNOTAVAIL) ? - "Can't assign requested address" : + "Can't assign requested address" : (no_ == WSAENETDOWN) ? - "Network is down" : + "Network is down" : (no_ == WSAENETUNREACH) ? - "Network is unreachable" : + "Network is unreachable" : (no_ == WSAENETRESET) ? - "Net dropped connection or reset" : + "Net dropped connection or reset" : (no_ == WSAECONNABORTED) ? - "Software caused connection abort" : + "Software caused connection abort" : (no_ == WSAECONNRESET) ? - "Connection reset by peer" : + "Connection reset by peer" : (no_ == WSAENOBUFS) ? - "No buffer space available" : + "No buffer space available" : (no_ == WSAEISCONN) ? - "Socket is already connected" : + "Socket is already connected" : (no_ == WSAENOTCONN) ? - "Socket is not connected" : + "Socket is not connected" : (no_ == WSAESHUTDOWN) ? - "Can't send after socket shutdown" : + "Can't send after socket shutdown" : (no_ == WSAETOOMANYREFS) ? - "Too many references can't splice" : + "Too many references can't splice" : (no_ == WSAETIMEDOUT) ? - "Connection timed out" : + "Connection timed out" : (no_ == WSAECONNREFUSED) ? - "Connection refused" : + "Connection refused" : (no_ == WSAELOOP) ? - "Too many levels of symbolic links" : + "Too many levels of symbolic links" : (no_ == WSAENAMETOOLONG) ? - "File name too long" : + "File name too long" : (no_ == WSAEHOSTDOWN) ? - "Host is down" : + "Host is down" : (no_ == WSAEHOSTUNREACH) ? - "No Route to Host" : + "No Route to Host" : (no_ == WSAENOTEMPTY) ? - "Directory not empty" : + "Directory not empty" : (no_ == WSAEPROCLIM) ? - "Too many processes" : + "Too many processes" : (no_ == WSAEUSERS) ? - "Too many users" : + "Too many users" : (no_ == WSAEDQUOT) ? - "Disc Quota Exceeded" : + "Disc Quota Exceeded" : (no_ == WSAESTALE) ? - "Stale NFS file handle" : + "Stale NFS file handle" : (no_ == WSAEREMOTE) ? - "Too many levels of remote in path" : + "Too many levels of remote in path" : (no_ == WSASYSNOTREADY) ? - "Network SubSystem is unavailable" : + "Network SubSystem is unavailable" : (no_ == WSAVERNOTSUPPORTED) ? - "WINSOCK DLL Version out of range" : + "WINSOCK DLL Version out of range" : (no_ == WSANOTINITIALISED) ? - "Successful WSASTARTUP not yet performed" : + "Successful WSASTARTUP not yet performed" : (no_ == WSAHOST_NOT_FOUND) ? - "Host not found" : + "Host not found" : (no_ == WSATRY_AGAIN) ? - "Non-Authoritative Host not found" : + "Non-Authoritative Host not found" : (no_ == WSANO_RECOVERY) ? - "Non-Recoverable errors: FORMERR REFUSED NOTIMP" : + "Non-Recoverable errors: FORMERR REFUSED NOTIMP" : (no_ == WSANO_DATA) ? "Valid name no data record of requested" : - "error not defined"; + "error not defined"; } void zmq::win_error (char *buffer_, size_t buffer_size_) diff --git a/src/err.hpp b/src/err.hpp index 374f12b3..8854fc31 100644 --- a/src/err.hpp +++ b/src/err.hpp @@ -122,7 +122,7 @@ namespace zmq __FILE__, __LINE__);\ zmq::zmq_abort (#x);\ }\ - } while (false) + } while (false) // Provides convenient way to check for errno-style errors. #define errno_assert(x) \ diff --git a/src/i_poll_events.hpp b/src/i_poll_events.hpp index 7e25e49d..1b28df8a 100644 --- a/src/i_poll_events.hpp +++ b/src/i_poll_events.hpp @@ -26,30 +26,30 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ - + #ifndef __ZMQ_I_POLL_EVENTS_HPP_INCLUDED__ #define __ZMQ_I_POLL_EVENTS_HPP_INCLUDED__ - + namespace zmq { - + // Virtual interface to be exposed by object that want to be notified // about events on file descriptors. - + struct i_poll_events { virtual ~i_poll_events () {} - + // Called by I/O thread when file descriptor is ready for reading. virtual void in_event () = 0; - + // Called by I/O thread when file descriptor is ready for writing. virtual void out_event () = 0; - + // Called when timer expires. virtual void timer_event (int id_) = 0; }; - + } - + #endif diff --git a/src/ipc_connecter.cpp b/src/ipc_connecter.cpp index 7ee3519c..bb3c2dd9 100644 --- a/src/ipc_connecter.cpp +++ b/src/ipc_connecter.cpp @@ -188,14 +188,14 @@ int zmq::ipc_connecter_t::get_new_reconnect_ivl () // Only change the current reconnect interval if the maximum reconnect // interval was set and if it's larger than the reconnect interval. - if (options.reconnect_ivl_max > 0 && + if (options.reconnect_ivl_max > 0 && options.reconnect_ivl_max > options.reconnect_ivl) { // Calculate the next interval current_reconnect_ivl = current_reconnect_ivl * 2; if(current_reconnect_ivl >= options.reconnect_ivl_max) { current_reconnect_ivl = options.reconnect_ivl_max; - } + } } return this_interval; } @@ -220,7 +220,7 @@ int zmq::ipc_connecter_t::open () // Connect was successful immediately. if (rc == 0) return 0; - + // Translate other error codes indicating asynchronous connect has been // launched to a uniform EINPROGRESS. if (rc == -1 && errno == EINTR) { diff --git a/src/lb.cpp b/src/lb.cpp index be06b48b..2787739e 100644 --- a/src/lb.cpp +++ b/src/lb.cpp @@ -110,7 +110,7 @@ int zmq::lb_t::sendpipe (msg_t *msg_, pipe_t **pipe_) // If send fails for multi-part msg rollback other // parts sent earlier and return EAGAIN. - // Application should handle this as suitable + // Application should handle this as suitable if (more) { pipes [current]->rollback (); diff --git a/src/mailbox_safe.cpp b/src/mailbox_safe.cpp index 3eaad766..4c593109 100644 --- a/src/mailbox_safe.cpp +++ b/src/mailbox_safe.cpp @@ -64,7 +64,7 @@ void zmq::mailbox_safe_t::remove_signaler(signaler_t* signaler) // TODO: make a copy of array and signal outside the lock for (; it != signalers.end(); ++it){ if (*it == signaler) - break; + break; } if (it != signalers.end()) @@ -92,7 +92,7 @@ int zmq::mailbox_safe_t::recv (command_t *cmd_, int timeout_) // Try to get the command straight away. if (cpipe.read (cmd_)) return 0; - + // Wait for signal from the command sender. int rc = cond_var.wait (sync, timeout_); if (rc == -1) { diff --git a/src/mailbox_safe.hpp b/src/mailbox_safe.hpp index c1ceb080..a909e90f 100644 --- a/src/mailbox_safe.hpp +++ b/src/mailbox_safe.hpp @@ -64,8 +64,8 @@ namespace zmq // close the file descriptors in the signaller. This is used in a forked // child process to close the file descriptors so that they do not interfere // with the context in the parent process. - void forked () - { + void forked () + { // TODO: call fork on the condition variable } #endif diff --git a/src/object.cpp b/src/object.cpp index 6c0fdd13..6c2a5afe 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -121,7 +121,7 @@ void zmq::object_t::process_command (command_t &cmd_) case command_t::term_req: process_term_req (cmd_.args.term_req.object); break; - + case command_t::term: process_term (cmd_.args.term.linger); break; @@ -194,7 +194,7 @@ zmq::io_thread_t *zmq::object_t::choose_io_thread (uint64_t affinity_) void zmq::object_t::send_stop () { // 'stop' command goes always from administrative thread to - // the current object. + // the current object. command_t cmd; cmd.destination = this; cmd.type = command_t::stop; diff --git a/src/own.cpp b/src/own.cpp index 8f47131e..b87f4ee0 100644 --- a/src/own.cpp +++ b/src/own.cpp @@ -183,7 +183,7 @@ void zmq::own_t::unregister_term_ack () term_acks--; // This may be a last ack we are waiting for before termination... - check_term_acks (); + check_term_acks (); } void zmq::own_t::process_term_ack () diff --git a/src/pgm_receiver.cpp b/src/pgm_receiver.cpp index 6192bd80..add18475 100644 --- a/src/pgm_receiver.cpp +++ b/src/pgm_receiver.cpp @@ -46,7 +46,7 @@ #include "wire.hpp" #include "err.hpp" -zmq::pgm_receiver_t::pgm_receiver_t (class io_thread_t *parent_, +zmq::pgm_receiver_t::pgm_receiver_t (class io_thread_t *parent_, const options_t &options_) : io_object_t (parent_), has_rx_timer (false), diff --git a/src/pgm_receiver.hpp b/src/pgm_receiver.hpp index c7f10d29..a603bf07 100644 --- a/src/pgm_receiver.hpp +++ b/src/pgm_receiver.hpp @@ -55,7 +55,7 @@ namespace zmq class pgm_receiver_t : public io_object_t, public i_engine { - + public: pgm_receiver_t (zmq::io_thread_t *parent_, const options_t &options_); diff --git a/src/pgm_sender.hpp b/src/pgm_sender.hpp index c05be228..1c56d6a4 100644 --- a/src/pgm_sender.hpp +++ b/src/pgm_sender.hpp @@ -111,7 +111,7 @@ namespace zmq // Output buffer from pgm_socket. unsigned char *out_buffer; - + // Output buffer size. size_t out_buffer_size; diff --git a/src/pgm_socket.hpp b/src/pgm_socket.hpp index 28f1f20b..3f871859 100644 --- a/src/pgm_socket.hpp +++ b/src/pgm_socket.hpp @@ -67,11 +67,11 @@ namespace zmq // Resolve PGM socket address. static int init_address(const char *network_, struct pgm_addrinfo_t **addr, uint16_t *port_number); - + // Get receiver fds and store them into user allocated memory. void get_receiver_fds (fd_t *receive_fd_, fd_t *waiting_pipe_fd_); - // Get sender and receiver fds and store it to user allocated + // Get sender and receiver fds and store it to user allocated // memory. Receive fd is used to process NAKs from peers. void get_sender_fds (fd_t *send_fd_, fd_t *receive_fd_, fd_t *rdata_notify_fd_, fd_t *pending_notify_fd_); @@ -88,7 +88,7 @@ namespace zmq long get_rx_timeout (); long get_tx_timeout (); - // POLLIN on sender side should mean NAK or SPMR receiving. + // POLLIN on sender side should mean NAK or SPMR receiving. // process_upstream function is used to handle such a situation. void process_upstream (); @@ -96,7 +96,7 @@ namespace zmq // Compute size of the buffer based on rate and recovery interval. int compute_sqns (int tpdu_); - + // OpenPGM transport. pgm_sock_t* sock; @@ -104,7 +104,7 @@ namespace zmq // Associated socket options. options_t options; - + // true when pgm_socket should create receiving side. bool receiver; @@ -120,7 +120,7 @@ namespace zmq // How many bytes were processed from last pgm socket read. size_t nbytes_processed; - + // How many messages from pgm_msgv were already sent up. size_t pgm_msgv_processed; }; diff --git a/src/pipe.hpp b/src/pipe.hpp index ae17cc93..cae54565 100644 --- a/src/pipe.hpp +++ b/src/pipe.hpp @@ -84,7 +84,7 @@ namespace zmq // Specifies the object to send events to. void set_event_sink (i_pipe_events *sink_); - // Pipe endpoint can store an routing ID to be used by its clients. + // Pipe endpoint can store an routing ID to be used by its clients. void set_routing_id (uint32_t routing_id_); uint32_t get_routing_id (); diff --git a/src/router.cpp b/src/router.cpp index 04f36d37..117e553a 100644 --- a/src/router.cpp +++ b/src/router.cpp @@ -299,7 +299,7 @@ int zmq::router_t::xrecv (msg_t *msg_) prefetched = false; } more_in = msg_->flags () & msg_t::more ? true : false; - + if (!more_in) { if (terminate_current_in) { current_in->terminate (true); diff --git a/src/router.hpp b/src/router.hpp index b1350f5c..f693000e 100644 --- a/src/router.hpp +++ b/src/router.hpp @@ -124,7 +124,7 @@ namespace zmq // algorithm. This value is the next ID to use (if not used already). uint32_t next_rid; - // If true, report EAGAIN to the caller instead of silently dropping + // If true, report EAGAIN to the caller instead of silently dropping // the message targeting an unknown peer. bool mandatory; bool raw_socket; diff --git a/src/select.cpp b/src/select.cpp index edc15821..a234a6f1 100644 --- a/src/select.cpp +++ b/src/select.cpp @@ -104,8 +104,8 @@ void zmq::select_t::rm_fd (handle_t handle_) if (family_entry_it != current_family_entry_it) { // Family is not currently being iterated and can be safely - // modified in palce. So later it can be skipped withour re-verifying - // its content. + // modified in-place. So later it can be skipped without + // re-verifying its content. fd_entries_t::iterator fd_entry_it; for (fd_entry_it = family_entry.fd_entries.begin (); fd_entry_it != family_entry.fd_entries.end (); ++fd_entry_it) @@ -441,7 +441,7 @@ u_short zmq::select_t::get_fd_family (fd_t fd_) int type; int type_length = sizeof(int); - + int rc = getsockopt(fd_, SOL_SOCKET, SO_TYPE, (char*) &type, &type_length); if (rc == 0) { @@ -453,11 +453,11 @@ u_short zmq::select_t::get_fd_family (fd_t fd_) // AF_INET and AF_INET6 can be mixed in select // TODO: If proven otherwise, should simply return addr.sa_family if (rc != SOCKET_ERROR) - return addr.ss_family == AF_INET6 ? AF_INET : addr.ss_family; + return addr.ss_family == AF_INET6 ? AF_INET : addr.ss_family; } - } + } - return AF_UNSPEC; + return AF_UNSPEC; } zmq::select_t::family_entry_t::family_entry_t () : diff --git a/src/server.hpp b/src/server.hpp index b788c0d9..7c2146d2 100644 --- a/src/server.hpp +++ b/src/server.hpp @@ -55,7 +55,7 @@ namespace zmq ~server_t (); // Overrides of functions from socket_base_t. - void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_); + void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_); int xsend (zmq::msg_t *msg_); int xrecv (zmq::msg_t *msg_); bool xhas_in (); @@ -72,7 +72,7 @@ namespace zmq // Fair queueing object for inbound pipes. fq_t fq; - + struct outpipe_t { zmq::pipe_t *pipe; @@ -82,11 +82,11 @@ namespace zmq // Outbound pipes indexed by the peer IDs. typedef std::map outpipes_t; outpipes_t outpipes; - + // Routing IDs are generated. It's a simple increment and wrap-over // algorithm. This value is the next ID to use (if not used already). uint32_t next_rid; - + server_t (const server_t&); const server_t &operator = (const server_t&); }; diff --git a/src/socket_poller.hpp b/src/socket_poller.hpp index 22878c9b..33b24625 100644 --- a/src/socket_poller.hpp +++ b/src/socket_poller.hpp @@ -61,7 +61,7 @@ namespace zmq { socket_base_t *socket; fd_t fd; - void *user_data; + void *user_data; short events; } event_t; @@ -79,7 +79,7 @@ namespace zmq bool check_tag (); private: - int rebuild (); + int rebuild (); // Used to check whether the object is a socket_poller. uint32_t tag; @@ -90,7 +90,7 @@ namespace zmq typedef struct item_t { socket_base_t *socket; fd_t fd; - void *user_data; + void *user_data; short events; #if defined ZMQ_POLL_BASED_ON_POLL int pollfd_index; @@ -106,10 +106,10 @@ namespace zmq // Should the signaler be used for the thread safe polling? bool use_signaler; - + // Size of the pollset int poll_size; - + #if defined ZMQ_POLL_BASED_ON_POLL pollfd *pollfds; #elif defined ZMQ_POLL_BASED_ON_SELECT @@ -118,7 +118,7 @@ namespace zmq fd_set pollset_err; zmq::fd_t maxfd; #endif - + socket_poller_t (const socket_poller_t&); const socket_poller_t &operator = (const socket_poller_t&); }; diff --git a/src/stream.hpp b/src/stream.hpp index 77c5cbe8..46fde477 100644 --- a/src/stream.hpp +++ b/src/stream.hpp @@ -57,7 +57,7 @@ namespace zmq void xread_activated (zmq::pipe_t *pipe_); void xwrite_activated (zmq::pipe_t *pipe_); void xpipe_terminated (zmq::pipe_t *pipe_); - int xsetsockopt (int option_, const void *optval_, size_t optvallen_); + int xsetsockopt (int option_, const void *optval_, size_t optvallen_); private: // Generate peer's id and update lookup map void identify_peer (pipe_t *pipe_); diff --git a/src/tcp.hpp b/src/tcp.hpp index 2ecc8dca..86870f79 100644 --- a/src/tcp.hpp +++ b/src/tcp.hpp @@ -62,4 +62,4 @@ namespace zmq } -#endif +#endif diff --git a/src/thread.hpp b/src/thread.hpp index cd555a41..1966589a 100644 --- a/src/thread.hpp +++ b/src/thread.hpp @@ -75,7 +75,7 @@ namespace zmq // they would not be accessible from the main C routine of the thread. thread_fn *tfn; void *arg; - + private: #ifdef ZMQ_HAVE_WINDOWS diff --git a/src/tweetnacl.c b/src/tweetnacl.c index 9fe1154b..1df51b08 100644 --- a/src/tweetnacl.c +++ b/src/tweetnacl.c @@ -479,7 +479,7 @@ int crypto_scalarmult(u8 *q,const u8 *n,const u8 *p) } int crypto_scalarmult_base(u8 *q,const u8 *n) -{ +{ return crypto_scalarmult(q,n,_9); } @@ -528,7 +528,7 @@ static u64 Sigma1(u64 x) { return R(x,14) ^ R(x,18) ^ R(x,41); } static u64 sigma0(u64 x) { return R(x, 1) ^ R(x, 8) ^ (x >> 7); } static u64 sigma1(u64 x) { return R(x,19) ^ R(x,61) ^ (x >> 6); } -static const u64 K[80] = +static const u64 K[80] = { 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, @@ -624,7 +624,7 @@ int crypto_hash(u8 *out,const u8 *m,u64 n) sv add(gf p[4],gf q[4]) { gf a,b,c,d,t,e,f,g,h; - + Z(a, p[1], p[0]); Z(t, q[1], q[0]); M(a, a, t); @@ -656,7 +656,7 @@ sv cswap(gf p[4],gf q[4],u8 b) sv pack(u8 *r,gf p[4]) { gf tx, ty, zi; - inv25519(zi, p[2]); + inv25519(zi, p[2]); M(tx, p[0], zi); M(ty, p[1], zi); pack25519(r, ty); diff --git a/src/xsub.cpp b/src/xsub.cpp index c474075d..3965afc6 100644 --- a/src/xsub.cpp +++ b/src/xsub.cpp @@ -105,13 +105,13 @@ int zmq::xsub_t::xsend (msg_t *msg_) subscriptions.add (data + 1, size - 1); return dist.send_to_all (msg_); } - else + else if (size > 0 && *data == 0) { // Process unsubscribe message if (subscriptions.rm (data + 1, size - 1)) return dist.send_to_all (msg_); } - else + else // User message sent upstream to XPUB socket return dist.send_to_all (msg_); @@ -155,7 +155,7 @@ int zmq::xsub_t::xrecv (msg_t *msg_) return -1; // Check whether the message matches at least one subscription. - // Non-initial parts of the message are passed + // Non-initial parts of the message are passed if (more || !options.filter || match (msg_)) { more = msg_->flags () & msg_t::more ? true : false; return 0; diff --git a/src/zmq_utils.cpp b/src/zmq_utils.cpp index a3479624..d4c51280 100644 --- a/src/zmq_utils.cpp +++ b/src/zmq_utils.cpp @@ -94,24 +94,24 @@ void zmq_threadclose(void* thread) // Maps base 256 to base 85 static char encoder [85 + 1] = { "0123456789" "abcdefghij" "klmnopqrst" "uvwxyzABCD" - "EFGHIJKLMN" "OPQRSTUVWX" "YZ.-:+=^!/" "*?&<>()[]{" + "EFGHIJKLMN" "OPQRSTUVWX" "YZ.-:+=^!/" "*?&<>()[]{" "}@%$#" }; // Maps base 85 to base 256 // We chop off lower 32 and higher 128 ranges static uint8_t decoder [96] = { - 0x00, 0x44, 0x00, 0x54, 0x53, 0x52, 0x48, 0x00, - 0x4B, 0x4C, 0x46, 0x41, 0x00, 0x3F, 0x3E, 0x45, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x40, 0x00, 0x49, 0x42, 0x4A, 0x47, - 0x51, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, - 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, - 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, - 0x3B, 0x3C, 0x3D, 0x4D, 0x00, 0x4E, 0x43, 0x00, - 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, + 0x00, 0x44, 0x00, 0x54, 0x53, 0x52, 0x48, 0x00, + 0x4B, 0x4C, 0x46, 0x41, 0x00, 0x3F, 0x3E, 0x45, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x40, 0x00, 0x49, 0x42, 0x4A, 0x47, + 0x51, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, + 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, + 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, + 0x3B, 0x3C, 0x3D, 0x4D, 0x00, 0x4E, 0x43, 0x00, + 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x4F, 0x00, 0x50, 0x00, 0x00 }; @@ -151,7 +151,7 @@ char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size) // -------------------------------------------------------------------------- // Decode an encoded string into a binary frame; dest must be at least -// strlen (string) * 4 / 5 bytes long. Returns dest. strlen (string) +// strlen (string) * 4 / 5 bytes long. Returns dest. strlen (string) // must be a multiple of 5. // Returns NULL and sets errno = EINVAL for invalid input.