0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-31 01:43:02 +08:00

Merge pull request #796 from hintjens/master

Fixes to IPC wildcarding & test cases
This commit is contained in:
Ian Barber 2013-12-20 13:36:30 -08:00
commit 93e26efd5d
6 changed files with 65 additions and 4 deletions

2
.gitignore vendored
View File

@ -22,6 +22,8 @@ autom4te.cache
.*~
tools/curve_keygen.o
tools/curve_keygen
tests/test_resource
tests/test_ipc_wildcard
tests/test_stream_empty
tests/test_issue_566
tests/test_ctx_destroy

View File

@ -53,8 +53,8 @@ int zmq::ipc_address_t::resolve (const char *path_)
}
#if defined ZMQ_HAVE_LINUX
if (path_[0] == '@' && !path_[1]) {
errno = EINVAL;
return -1;
errno = EINVAL;
return -1;
}
#endif

View File

@ -133,9 +133,11 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
// Allow wildcard file
if (addr [0] == '*') {
char buffer [12] = "2134XXXXXX";
if (mkstemp (buffer) == -1)
int fd = mkstemp (buffer);
if (fd == -1)
return -1;
addr.assign (buffer);
::close (fd);
}
// Get rid of the file associated with the UNIX domain socket that

View File

@ -44,6 +44,7 @@ noinst_PROGRAMS = test_system \
test_proxy \
test_abstract_ipc \
test_many_sockets \
test_ipc_wildcard \
test_diffserv
if !ON_MINGW
@ -108,6 +109,7 @@ test_issue_566_SOURCES = test_issue_566.cpp
test_proxy_SOURCES = test_proxy.cpp
test_abstract_ipc_SOURCES = test_abstract_ipc.cpp
test_many_sockets_SOURCES = test_many_sockets.cpp
test_ipc_wildcard_SOURCES = test_ipc_wildcard.cpp
test_diffserv_SOURCES = test_diffserv.cpp
if !ON_MINGW
test_shutdown_stress_SOURCES = test_shutdown_stress.cpp

View File

@ -193,7 +193,7 @@ int main (void)
assert (rc == 0);
// Give time to process disconnect
msleep (SETTLE_TIME);
msleep (SETTLE_TIME * 10);
// Send a message, should fail
rc = zmq_send (frontend, "Hello", 5, ZMQ_DONTWAIT);

View File

@ -0,0 +1,55 @@
/*
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "testutil.hpp"
int main (void)
{
setup_test_environment();
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PAIR);
assert (sb);
int rc = zmq_bind (sb, "ipc://*");
assert (rc == 0);
char endpoint [200];
size_t size = sizeof (endpoint);
rc = zmq_getsockopt (sb, ZMQ_LAST_ENDPOINT, endpoint, &size);
assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_PAIR);
assert (sc);
rc = zmq_connect (sc, endpoint);
assert (rc == 0);
bounce (sb, sc);
rc = zmq_close (sc);
assert (rc == 0);
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;
}