Пример #1
0
void
zproxy_pause (zproxy_t *self)
{
    assert (self);
    zstr_send (self->pipe, "PAUSE");
    zsocket_wait (self->pipe);
}
Пример #2
0
PoolServer::~PoolServer(){
	
	printf("PoolServer stopping...\n");
	
	proto::Signal sig;
	sig.set_type(proto::Signal_Type_SHUTDOWN);
	
	SendSignal(sig, mWorkerSignals);
	
	for(unsigned i = 0; i < mWorkers.size(); ++i){
		
		zsocket_wait(mWorkers[i].second);
		delete mWorkers[i].first;
		
	}
	
	delete mFrontend;
	delete mBackend;
	
	zsocket_destroy(mCtx, mWorkerSignals);
	zctx_destroy(&mCtx);
	
	printf("PoolServer stopped.\n");
	
}
Пример #3
0
void
zproxy_resume (zproxy_t *self)
{
    assert (self);
    zstr_send (self->pipe, "RESUME");
    zsocket_wait (self->pipe);
}
Пример #4
0
void
zproxy_capture (zproxy_t *self, const char *endpoint)
{
    assert (self);
    zstr_sendm (self->pipe, "CAPTURE");
    zstr_send (self->pipe, endpoint);
    zsocket_wait (self->pipe);
}
Пример #5
0
void
zauth_set_verbose (zauth_t *self, bool verbose)
{
    assert (self);
    zstr_sendm (self->pipe, "VERBOSE");
    zstr_sendf (self->pipe, "%d", verbose);
    zsocket_wait (self->pipe);
}
Пример #6
0
void
zauth_configure_gssapi (zauth_t *self, char *domain)
{
    assert (self);
    assert (domain);
    zstr_sendx (self->pipe, "GSSAPI", domain, NULL);
    zsocket_wait (self->pipe);
}
Пример #7
0
void
zauth_configure_curve (zauth_t *self, const char *domain, const char *location)
{
    assert (self);
    assert (domain);
    assert (location);
    zstr_sendx (self->pipe, "CURVE", domain, location, NULL);
    zsocket_wait (self->pipe);
}
Пример #8
0
void
zauth_configure_plain (zauth_t *self, const char *domain, const char *filename)
{
    assert (self);
    assert (domain);
    assert (filename);
    zstr_sendx (self->pipe, "PLAIN", domain, filename, NULL);
    zsocket_wait (self->pipe);
}
Пример #9
0
void
zproxy_destroy (zproxy_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zproxy_t *self = *self_p;
        zstr_send (self->pipe, "STOP");
        zsocket_wait (self->pipe);
        free (self);
        *self_p = NULL;
    }
}
Пример #10
0
zproxy_t *
zproxy_new (zctx_t *ctx, void *frontend, void *backend)
{
    assert (ctx);
    zproxy_t *self = (zproxy_t *) zmalloc (sizeof (zproxy_t));
    if (self) {
        self->ctx = ctx;
        self->frontend = frontend;
        self->backend = backend;
        self->pipe = zthread_fork (ctx, s_proxy_task, self);
        if (self->pipe)
            zsocket_wait (self->pipe);
        else {
            //  If we ran out of sockets, signal failure to caller
            zproxy_destroy (&self);
        }
    }
    return self;
}
Пример #11
0
PoolServer::PoolServer(CWallet* pwallet) {
	
	printf("PoolServer started.\n");
	
	mWallet = pwallet;
	
	mBackend = new PoolBackend(pwallet);
	
	mCtx = zctx_new();
	
	mWorkerSignals = zsocket_new(mCtx, ZMQ_PUB);
	zsocket_bind(mWorkerSignals, "inproc://bitcoin");
	
	mBackendDealer = 0;
	
	mMinShare = mBackend->Settings().MinShare;
	mTarget = mBackend->Settings().Target;
	
	int nThreads = GetArg("-genproclimit", 2);
	for(int i = 0; i < nThreads; ++i){
		
		PrimeWorker* worker = new PrimeWorker(mWallet, i, mTarget);
		
		void* pipe = zthread_fork(mCtx, &PrimeWorker::InvokeWork, worker);
		zsocket_wait(pipe);
		
		mWorkers.push_back(std::make_pair(worker, pipe));
		
	}
	
	mFrontend = new PoolFrontend(GetArg("-frontport", 6666));
	
	if(GetArg("-testinv", 0)){
		printf("STARTING TESTINV!!!\n");
		zthread_fork(mCtx, &thread_test_inv, (void*)GetArg("-testinv", 0));
	}
	
}
Пример #12
0
void
zsocket_test (bool verbose)
{
    printf (" * zsocket (deprecated): ");

    //  @selftest
    zctx_t *ctx = zctx_new ();
    assert (ctx);

    //  Create a detached thread, let it run
    char *interf = "127.0.0.1";
    char *domain = "localhost";
    int service = 5560;

    void *writer = zsocket_new (ctx, ZMQ_PUSH);
    assert (writer);
    void *reader = zsocket_new (ctx, ZMQ_PULL);
    assert (reader);
    assert (streq (zsocket_type_str (writer), "PUSH"));
    assert (streq (zsocket_type_str (reader), "PULL"));
    int rc = zsocket_bind (writer, "tcp://%s:%d", interf, service);
    assert (rc == service);

#if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0))
    //  Check unbind
    rc = zsocket_unbind (writer, "tcp://%s:%d", interf, service);
    assert (rc == 0);

    //  In some cases and especially when running under Valgrind, doing
    //  a bind immediately after an unbind causes an EADDRINUSE error.
    //  Even a short sleep allows the OS to release the port for reuse.
    zclock_sleep (100);

    //  Bind again
    rc = zsocket_bind (writer, "tcp://%s:%d", interf, service);
    assert (rc == service);
#endif

    rc = zsocket_connect (reader, "tcp://%s:%d", domain, service);
    assert (rc == 0);
    zstr_send (writer, "HELLO");
    char *message = zstr_recv (reader);
    assert (message);
    assert (streq (message, "HELLO"));
    free (message);

    //  Test binding to ports
    int port = zsocket_bind (writer, "tcp://%s:*", interf);
    assert (port >= ZSOCKET_DYNFROM && port <= ZSOCKET_DYNTO);

    assert (zsocket_poll (writer, 100) == false);

    //  Test error state when connecting to an invalid socket type
    //  ('txp://' instead of 'tcp://', typo intentional)
    rc = zsocket_connect (reader, "txp://%s:%d", domain, service);
    assert (rc == -1);

    //  Test sending frames to socket
    rc = zsocket_sendmem (writer, "ABC", 3, ZFRAME_MORE);
    assert (rc == 0);
    rc = zsocket_sendmem (writer, "DEFG", 4, 0);
    assert (rc == 0);

    zframe_t *frame = zframe_recv (reader);
    assert (frame);
    assert (zframe_streq (frame, "ABC"));
    assert (zframe_more (frame));
    zframe_destroy (&frame);

    frame = zframe_recv (reader);
    assert (frame);
    assert (zframe_streq (frame, "DEFG"));
    assert (!zframe_more (frame));
    zframe_destroy (&frame);

    rc = zsocket_signal (writer);
    assert (rc == 0);
    rc = zsocket_wait (reader);
    assert (rc == 0);

    zsocket_destroy (ctx, reader);
    zsocket_destroy (ctx, writer);
    zctx_destroy (&ctx);
    //  @end

    printf ("OK\n");
}
Пример #13
0
void
zauth_allow (zauth_t *self, const char *address)
{
    zstr_sendx (self->pipe, "ALLOW", address, NULL);
    zsocket_wait (self->pipe);
}
Пример #14
0
void
zauth_deny (zauth_t *self, const char *address)
{
    zstr_sendx (self->pipe, "DENY", address, NULL);
    zsocket_wait (self->pipe);
}