示例#1
0
文件: server.c 项目: yichi-lu/openssl
int main(int argc, char *argv[])
{
    BIO         *acc, *client;
    THREAD_TYPE tid;
 
    init_OpenSSL(  );
 
    acc = BIO_new_accept(PORT);
    if (!acc)
        int_error("Error creating server socket");
  
    if (BIO_do_accept(acc) <= 0)
        int_error("Error binding server socket");

  
    for (;;)
    {
        if (BIO_do_accept(acc) <= 0)
            int_error("Error accepting connection");
 

        client = BIO_pop(acc);
        THREAD_CREATE(tid, server_thread,  client);

    }
 
    BIO_free(acc);
    return 0;
}
示例#2
0
fast_mtq fast_mtq_start_stop_init(int threads, fast_mtq_cb cb, void *arg,
				  fast_mtq_start_cb start_cb,
				  fast_mtq_stop_cb stop_cb)
{
	fast_mtq f_mtq;
	int i;

	log_debug("Fast mtq init, threads:%d", threads);

	f_mtq =
	    (fast_mtq) malloc(sizeof(_fast_mtq) +
			      (threads * sizeof(THREAD_VAR)));
	memset(f_mtq, 0, sizeof(_fast_mtq));
	f_mtq->threads = threads;
	f_mtq->cb = cb;
	f_mtq->start_cb = start_cb;
	f_mtq->stop_cb = stop_cb;
	f_mtq->arg = arg;
	f_mtq->shutdown = 0;
	f_mtq->first = NULL;
	f_mtq->last = NULL;
	f_mtq->queue = 0;

	SEM_INIT(f_mtq->sem);
	COND_INIT(f_mtq->cond);

	for (i = 0; i < f_mtq->threads; i++) {
		THREAD_CREATE(f_mtq->threads_table[i], fast_mtq_thread,
			      f_mtq);
	}

	return f_mtq;
}
示例#3
0
static void setup(void) {
    running = true;
    config = UA_ServerConfig_new_default();
    server = UA_Server_new(config);
    UA_Server_run_startup(server);
    THREAD_CREATE(server_thread, serverloop);
}
void on_button_Connect_clicked(GtkWidget* w, gpointer data)
{
  int index = GPOINTER_TO_INT(data);
  struct connectThreadArg_s* arg;
  /* First, check to see if the requested mobot is a DOF. If it is, we must
   * ensure that the dongle has been connected. */
  if(
      (strlen(g_robotManager->getEntry(index)) == 4) &&
      (
       g_mobotParent == NULL ||
       (
        ((mobot_t*)g_mobotParent)->connected == 0
       )
      )
    )
  {
    /* Trying to connect to a DOF, but there is no dongle connected. Open the
     * connect-dongle dialog */
    g_mobotParent = (recordMobot_t*)malloc(sizeof(recordMobot_t));
    RecordMobot_init(g_mobotParent, "Dongle");
    askConnectDongle();
    /* If the dongle is still not connected, just return */
    if( (g_mobotParent == NULL) || (((mobot_t*)g_mobotParent)->connected == 0)) {
      return;
    }
  }
  arg = (struct connectThreadArg_s*)malloc(sizeof(struct connectThreadArg_s));
  arg->connectIndex = index;
  arg->connectionCompleted = 0;
  gtk_widget_set_sensitive(w, FALSE);
  THREAD_T thread;
  THREAD_CREATE(&thread, connectThread, arg);
  g_timeout_add(500, progressBarConnectUpdate, arg);
}
示例#5
0
bool Trace::ConnectToFileAndStart(char *filename, unsigned int trace_index, int register_size, int register_count, bool is_big_endian) {
  trace_index_ = trace_index;
  is_big_endian_ = is_big_endian;
  register_size_ = register_size;
  register_count_ = register_count;
  RWLOCK_INIT(db_lock_);
  MUTEX_INIT(backing_mutex_);

  registers_.resize(register_count_);

#ifdef _WIN32
  fd_ = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#else
  fd_ = open(filename, O_RDONLY);
  if (fd_ == -1) {
    printf("ERROR: file open failed\n");
    return false;
  }
#endif

  if (!remap_backing(sizeof(struct change))) {
    printf("ERROR: remap backing failed\n");
    return false;
  }

  THREAD_CREATE(thread, thread_entry, this);
  return true;
}
VOID ServiceConnection(IACP *iacp)
{
THREAD tid;
CLIENT *client;
static CHAR *fid = "ServiceConnection";

    BlockOnShutdown();

/* Grab the next available CLIENT slot */

    if ((client = NextAvailableClient(iacp)) == NULL) {
        LogMsg(LOG_WARN, "WARNING: new connection rejected (threshold reached)");
        BreakNewConnection(iacp, IACP_ALERT_SERVER_BUSY);
        return;
    }

/* Otherwise, leave behind a thread to deal with it */

    if (!THREAD_CREATE(&tid, ServiceThread, client)) {
        LogMsg(LOG_ERR, "%s: %s: THREAD_CREATE: %s", client->ident, fid, strerror(errno));
        BreakNewConnection(iacp, IACP_ALERT_SERVER_FAULT);
        return;
    }
    THREAD_DETACH(tid);
}
void StartSignalHandler(QHLP_PAR *arg)
{
int status;
THREAD tid;
sigset_t set;
static char *fid = "StartSignalHandler";

    par = arg;

/* Block all signals */
/* We keep the pthread specific function in place because there is no
 * easy way to emulate this under Windows.  This should not be a problem 
 * because this whole section is ifdef'd out under Windows and is known to
 * work under Solaris/Linux (where the THREAD macros are pthread based).
 */

    sigfillset(&set);
    pthread_sigmask(SIG_SETMASK, &set, NULL);

/* Create signal handling thread to catch all nondirected signals */

    if (!THREAD_CREATE(&tid, SignalHandlerThread, (void *) NULL)) {
        LogMsg("%s: THREAD_CREATE: %s", fid, strerror(errno));
        Exit(MY_MOD_ID);
    }
}
示例#8
0
static void setup(void) {
    running = true;
    server = UA_Server_new();
    UA_ServerConfig_setDefault(UA_Server_getConfig(server));
    UA_Server_run_startup(server);
    THREAD_CREATE(server_thread, serverloop);
}
示例#9
0
/* =============================================================================
 * thread_startup
 * -- Create pool of secondary threads
 * -- numThread is total number of threads (primary + secondaries)
 * =============================================================================
 */
void
thread_startup (long numThread)
{
    long i;

    global_numThread = numThread;
    global_doShutdown = FALSE;

    /* Set up barrier */
    assert(global_barrierPtr == NULL);
    global_barrierPtr = THREAD_BARRIER_ALLOC(numThread);
    assert(global_barrierPtr);
    THREAD_BARRIER_INIT(global_barrierPtr, numThread);

#ifdef MAP_USE_TFAVLTREE
#ifdef SEPERATE_MAINTENANCE
    thread_done = (bool_t *)malloc((numThread -4) * sizeof(bool_t));
    for(i = 0; i < numThread -4; i++) {
      thread_done[i] = FALSE;
    }
    /* assert(global_barrierPtr2 == NULL); */
    /* global_barrierPtr2 = THREAD_BARRIER_ALLOC(numThread-4); */
    /* assert(global_barrierPtr2); */
    /* THREAD_BARRIER_INIT(global_barrierPtr2, numThread-4); */

    /* assert(global_barrierPtr3 == NULL); */
    /* global_barrierPtr3 = THREAD_BARRIER_ALLOC(4); */
    /* assert(global_barrierPtr3); */
    /* THREAD_BARRIER_INIT(global_barrierPtr3, 4); */
#endif
#endif
    /* Set up ids */
    THREAD_LOCAL_INIT(global_threadId);
    assert(global_threadIds == NULL);
    global_threadIds = (long*)malloc(numThread * sizeof(long));
    assert(global_threadIds);
    for (i = 0; i < numThread; i++) {
        global_threadIds[i] = i;
    }

    /* Set up thread list */
    assert(global_threads == NULL);
    global_threads = (THREAD_T*)malloc(numThread * sizeof(THREAD_T));
    assert(global_threads);

    /* Set up pool */
    THREAD_ATTR_INIT(global_threadAttr);
    for (i = 1; i < numThread; i++) {
        THREAD_CREATE(global_threads[i],
                      global_threadAttr,
                      &threadWait,
                      &global_threadIds[i]);
    }

    /*
     * Wait for primary thread to call thread_start
     */
}
示例#10
0
void msocket_server_start(msocket_server_t *self,const char *udpAddr,uint16_t udpPort,uint16_t tcpPort){
   if(self != 0){
      self->tcpPort = tcpPort;
      self->udpPort = udpPort;
      if(udpAddr != 0){
         self->udpAddr = strdup(udpAddr);
      }
      msocket_sethandler(self->acceptSocket,&self->handlerTable,self->handlerArg);
      msocket_start_io(self->acceptSocket);
#ifdef _WIN32
   THREAD_CREATE(self->acceptThread,acceptTask,(void*) self,self->acceptThreadId);
   THREAD_CREATE(self->cleanupThread,cleanupTask,(void*) self,self->cleanupThreadId);
#else
   THREAD_CREATE(self->acceptThread,acceptTask,(void*) self);
   THREAD_CREATE(self->cleanupThread,cleanupTask,(void*) self);
#endif
   }
}
static void setup(void) {
    running = true;
    config = UA_ServerConfig_new_default();
    server = UA_Server_new(config);
    UA_Server_run_startup(server);
    THREAD_CREATE(server_thread, serverloop);
    /* Waiting server is up */
    UA_comboSleep(1000);
}
示例#12
0
   void Timer::start() {

      if (!active) {

         MUTEX_LOCK(game->timerMutex);
         active = true;
         THREAD_CREATE(jobThread, doTick, this, "Failed to start the timer!\n");
         MUTEX_UNLOCK(game->timerMutex);
      }
   }
示例#13
0
void StartLissReader(ISIDL_PAR *par)
{
THREAD tid;
static char *fid = "StartLissReader";

    if (!THREAD_CREATE(&tid, LissThread, (void *) par)) {
        LogMsg(LOG_INFO, "%s: THREAD_CREATE: LissThread: %s", fid, strerror(errno));
        Exit(MY_MOD_ID + 1);
    }
}
示例#14
0
   void Timer::insertJob(TimerJob *job) {

      DoInsertJobArg *arg = new DoInsertJobArg();

      arg->game = game;
      arg->timer = this;
      arg->job = job;
      
      // insert job asynchronously to avoid deadlock when a function called by
      // a job inserts another job
      THREAD_CREATE(insertJobThread, doInsertJob, arg, "Failed to insert timer job!\n");
   }
示例#15
0
int lstage_newthread(lua_State *L,pool_t pool) {
	_DEBUG("Creating new thread for pool %p\n",pool);
	thread_t * thread=lua_newuserdata(L,sizeof(thread_t));
	thread_t t=malloc(sizeof(struct thread_s));
	t->th=calloc(1,sizeof(THREAD_T));
	t->pool=pool;
	t->state=THREAD_IDLE;
	*thread=t;
   get_metatable(L);
   lua_setmetatable(L,-2);
   THREAD_CREATE(t->th, thread_mainloop, t, 0 );
   return 1;
}
static void setup(void) {
    running = true;
    config = UA_ServerConfig_new_default();
    config->pubsubTransportLayers = (UA_PubSubTransportLayer *) UA_malloc(sizeof(UA_PubSubTransportLayer));
    if(!config->pubsubTransportLayers) {
        UA_ServerConfig_delete(config);
    }
    config->pubsubTransportLayers[0] = UA_PubSubTransportLayerUDPMP();
    config->pubsubTransportLayersSize++;
    server = UA_Server_new(config);
    UA_Server_run_startup(server);
    THREAD_CREATE(server_thread, serverloop);
}
示例#17
0
// Start the log parsing thread.
void startup_logparse_thread(void) {
	int ret;

	LogQueue = new MLogmsgQueue(MAX_QUEUE_SIZE);
	HookQueue = new MFuncQueue(MAX_QUEUE_SIZE);

	ret=THREAD_CREATE(&logparse_thread_id, logparse_handler);
	if(ret != THREAD_OK) {
		// For now, we just exit if this fails.
		META_ERROR("Couldn't start thread for log parsing!  Exiting...");
		do_exit(1);
	}
}
示例#18
0
/* =============================================================================
 * thread_startup
 * -- Create pool of secondary threads
 * -- numThread is total number of threads (primary + secondaries)
 * =============================================================================
 */
void
thread_startup (long numThread)
{
    long i;

    totalThreads = numThread;

    global_numThread = numThread;
    global_doShutdown = FALSE;

    /* Set up barrier */
    assert(global_barrierPtr == NULL);
    global_barrierPtr = THREAD_BARRIER_ALLOC(numThread);
    assert(global_barrierPtr);
    THREAD_BARRIER_INIT(global_barrierPtr, numThread);

    /* Set up ids */
    THREAD_LOCAL_INIT(global_threadId);
    assert(global_threadIds == NULL);
    global_threadIds = (long*)malloc(numThread * sizeof(long));
    assert(global_threadIds);
    for (i = 0; i < numThread; i++) {
        global_threadIds[i] = i;
    }

    /* Set up thread list */
    assert(global_threads == NULL);
    global_threads = (THREAD_T*)malloc(numThread * sizeof(THREAD_T));
    assert(global_threads);

    threadArgsArr = (thread_args_t*) malloc(numThread * sizeof(thread_args_t));
    threadArgsArr[0].aborts = 0;
    threadArgsArr[0].commits = 0;
    threadArgsArr[0].threadId = global_threadIds[0];

    /* Set up pool */
    THREAD_ATTR_INIT(global_threadAttr);
    for (i = 1; i < numThread; i++) {
        threadArgsArr[i].aborts = 0;
        threadArgsArr[i].commits = 0;
        threadArgsArr[i].threadId = global_threadIds[i];
        THREAD_CREATE(global_threads[i],
                      global_threadAttr,
                      &threadWait,
                      &(threadArgsArr[i]));
    }

    /*
     * Wait for primary thread to call thread_start
     */
}
boolean extract_emergency_phr(char *phr_download_to_path, void (*backend_alert_msg_callback_handler_ptr)(char *alert_msg))
{
	// Setup a callback handler
	backend_alert_msg_callback_handler = backend_alert_msg_callback_handler_ptr;

	// Passing variable
	ptr_phr_download_to_path = &phr_download_to_path;

	init_main();

	// Create an emergency PHR extraction thread
	if(THREAD_CREATE(emergency_phr_extraction_thread_id, extract_emergency_phr_main, NULL) != 0)
		int_error("Creating a thread for \"extract_emergency_phr_main\" failed");

	while(1)
	{
		if(sem_wait(&wake_up_main_thread_mutex) != 0)
			int_error("Locking the mutex failed");

		// The emergency PHR extraction thread terminated
		if(emergency_phr_extraction_thread_terminated_flag)
			break;

		// Send an error message to frontend
		if(strlen(err_msg_to_frontend) > 0)
		{
			backend_alert_msg_handler_callback(err_msg_to_frontend);
			strcpy(err_msg_to_frontend, "");

			if(sem_post(&confirm_err_msg_sending_to_frontend_mutex) != 0)
				int_error("Unlocking the mutex failed");
		}
	}

	// Join the emergency PHR extraction thread
	if(THREAD_JOIN(emergency_phr_extraction_thread_id) != 0)
		int_error("Joining a thread \"extract_emergency_phr_main\" failed");

	// Send signal to confirm that the emergency PHR extraction thread has been terminated if the action was performed by a cancellation thread
	if(emergency_phr_extracting_cancellation_flag)
	{
		if(sem_post(&send_signal_to_confirm_cancellation_thread_mutex) != 0)
			int_error("Unlocking the mutex failed");

		if(sem_wait(&cancellation_thread_got_confirmation_mutex) != 0)
			int_error("Locking the mutex failed");
	}

	uninit_main();
	return transaction_success_status_flag;
}
示例#20
0
VOID StartStatusServer(PARAM *par)
{
THREAD tid;
static UINT16 StaticPort;
static char *fid = "StartStatusServer";

    StaticPort = par->status;

    if (!THREAD_CREATE(&tid, StatusServer, (void *) &StaticPort)) {
        LogMsg(LOG_ERR, "%s: THREAD_CREATE: %s", fid, strerror(errno));
        GracefulExit(MY_MOD_ID + 0);
    }
    THREAD_DETACH(tid);
}
void on_button_playRecorded_clicked(GtkWidget*button, gpointer data) 
{
  GtkWidget *w;
  /* Disable the play button */
  w = GTK_WIDGET(gtk_builder_get_object(g_builder, "button_playRecorded"));
  gtk_widget_set_sensitive(w, FALSE);
  teachingDialog_refreshRecordedMotions(0);
  /* Start the play thread */
  g_haltPlayFlag = false;
  g_isPlaying = true;
  THREAD_T thread;
  THREAD_CREATE(&thread, playThread, NULL);
  g_timeout_add(200, poseGuiTimeout, NULL);
}
示例#22
0
文件: open.c 项目: Fran89/seiscomp3
/*---------------------------------------------------------------------*/
H_ARCHIVE ArchiveOpenForWrite(CHAR * path)
{
    H_ARCHIVE harchive;
    ARCHIVE *archive;

    ArchiveLog(ARC_LOG_VERBOSE, "Open archive for write: %s", path);

    _archive_error = ARC_NO_ERROR;

    /* Get next available handle */
    if ((harchive = GetNextHandle()) == VOID_H_ARCHIVE)
        return (VOID_H_ARCHIVE);

    _archive[harchive].last_error = ARC_NO_ERROR;

    /* Check out the path */
    if (!ValidatePath(path, harchive))
        return (VOID_H_ARCHIVE);

    /* Create stream list */
    if (!CreateList(&_archive[harchive].streams)) {
        _archive_error = ARC_NO_MEMORY;
        return (VOID_H_ARCHIVE);
    }

    /* Get state and lock for write access */
    if (!OpenStateForWrite(harchive)) {
        _archive_error = _archive[harchive].last_error;
        return (VOID_H_ARCHIVE);
    }

    _n_archives++;

    /* Start the purge thread... */
    archive = &_archive[harchive];
    if (archive->state.thres_bytes != VOID_UINT64) {
        MUTEX_LOCK(&archive->purge.mutex);
        if(!archive->purge.active ) {
            ArchiveLog(ARC_LOG_VERBOSE, "Starting purge thread");
            if(!THREAD_CREATE(&archive->purge.thread_id, PurgeThread, &archive->purge)) {
                MUTEX_UNLOCK(&archive->purge.mutex);
                _archive_error = ARC_PURGE_THREAD;
                return (VOID_H_ARCHIVE);
            }
        }
        MUTEX_UNLOCK(&archive->purge.mutex);
    }

    return (harchive);
}
示例#23
0
void msocket_server_unix_start(msocket_server_t *self,const char *socketPath)
{
   if(self != 0){
      self->tcpPort = 0;
      self->udpPort = 0;
      if (socketPath != 0)
      {
         if (*socketPath=='\0')
         {
            int len=strlen(socketPath+1)+2;
            self->socketPath=(char*) malloc(len);
            if (self->socketPath != 0)
            {
               memcpy(self->socketPath+1,socketPath,len);
            }
         }
         else
         {
            self->socketPath=strdup(socketPath);
#ifdef _WIN32
            _unlink(socketPath);
#else
            unlink(socketPath);
#endif
         }
      }
//      msocket_sethandler(self->acceptSocket,&self->handlerTable,self->handlerArg);
//      msocket_start_io(self->acceptSocket);
#ifdef _WIN32
   THREAD_CREATE(self->acceptThread,acceptTask,(void*) self,self->acceptThreadId);
   THREAD_CREATE(self->cleanupThread,cleanupTask,(void*) self,self->cleanupThreadId);
#else
   THREAD_CREATE(self->acceptThread,acceptTask,(void*) self);
   THREAD_CREATE(self->cleanupThread,cleanupTask,(void*) self);
#endif
   }
}
示例#24
0
void FlushIsoImage()
{
THREAD tid;
static char *fid = "FlushIsoImage";

    MUTEX_LOCK(&LocalMutex);
        if (Enabled && !ActiveFlag) {
            ActiveFlag = TRUE;
            if (!THREAD_CREATE(&tid, FlushIsoImageThread, NULL)) {
                util_log(1, "%s: failed to start FlushIsoImageThread", fid);
                ispd_die(MY_MOD_ID + 2);
            }
        }
    MUTEX_UNLOCK(&LocalMutex);
}
示例#25
0
static void setup_lds(void) {
    // start LDS server
    running_lds = UA_Boolean_new();
    *running_lds = true;

    server_lds = UA_Server_new();
    configure_lds_server(server_lds);

    UA_Server_run_startup(server_lds);
    THREAD_CREATE(server_thread_lds, serverloop_lds);

    // wait until LDS started
    UA_fakeSleep(1000);
    UA_realSleep(1000);
}
void* findDongleThread(void* arg)
{
  static int args[MAX_COMPORT];
  int i;
  THREAD_T threads[MAX_COMPORT];
  for(i = 0; i < MAX_COMPORT; i++) {
    args[i] = i;
  }
  g_dongleSearchStatus = DONGLE_SEARCHING;
  /* Spawn worker threads to find the dongle on a com port */
  for(i = 0; i < MAX_COMPORT; i++) { 
    /* First, make sure there are less than MAX_THREADS running */
    MUTEX_LOCK(&g_giant_lock);
    while(
        (g_numThreads >= MAX_THREADS) &&
        (g_dongleSearchStatus == DONGLE_SEARCHING)
        ) 
    {
      COND_WAIT(&g_giant_cond, &g_giant_lock);
    }
    if(g_dongleSearchStatus != DONGLE_SEARCHING) {
      i++;
      MUTEX_UNLOCK(&g_giant_lock);
      break;
    }
    /* Spawn a thread */
    THREAD_CREATE(&threads[i], findDongleWorkerThread, &args[i]);
    g_numThreads++;
    MUTEX_UNLOCK(&g_giant_lock);
  }
  /* Join all threads */
  int j;
  for(j = 0; j < i; j++) {
    MUTEX_LOCK(&g_giant_lock);
    if(g_dongleSearchStatus != DONGLE_SEARCHING) {
      MUTEX_UNLOCK(&g_giant_lock);
      break;
    }
    MUTEX_UNLOCK(&g_giant_lock);
    THREAD_JOIN(threads[j]);
  }
  MUTEX_LOCK(&g_giant_lock);
  if(g_dongleSearchStatus == DONGLE_SEARCHING) {
    g_dongleSearchStatus = DONGLE_NOTFOUND;
  }
  MUTEX_UNLOCK(&g_giant_lock);
  return NULL;
}
示例#27
0
int
httpd_start(httpd_t *httpd, unsigned short *port)
{
	assert(httpd);
	assert(port);

	MUTEX_LOCK(httpd->run_mutex);
	if (httpd->running || !httpd->joined) {
		MUTEX_UNLOCK(httpd->run_mutex);
		return 0;
	}

	httpd->server_fd4 = netutils_init_socket(port, 0, 0);
	if (httpd->server_fd4 == -1) {
		logger_log(httpd->logger, LOGGER_ERR, "Error initialising socket %d", SOCKET_GET_ERROR());
		MUTEX_UNLOCK(httpd->run_mutex);
		return -1;
	}
	httpd->server_fd6 = netutils_init_socket(port, 1, 0);
	if (httpd->server_fd6 == -1) {
		logger_log(httpd->logger, LOGGER_WARNING, "Error initialising IPv6 socket %d", SOCKET_GET_ERROR());
		logger_log(httpd->logger, LOGGER_WARNING, "Continuing without IPv6 support");
	}

	if (listen(httpd->server_fd4, 5) == -1) {
		logger_log(httpd->logger, LOGGER_ERR, "Error listening to IPv4 socket");
		closesocket(httpd->server_fd4);
		closesocket(httpd->server_fd6);
		MUTEX_UNLOCK(httpd->run_mutex);
		return -2;
	}
	if (httpd->server_fd6 != -1 && listen(httpd->server_fd6, 5) == -1) {
		logger_log(httpd->logger, LOGGER_ERR, "Error listening to IPv6 socket");
		closesocket(httpd->server_fd4);
		closesocket(httpd->server_fd6);
		MUTEX_UNLOCK(httpd->run_mutex);
		return -2;
	}
	logger_log(httpd->logger, LOGGER_INFO, "Initialized server socket(s)");

	/* Set values correctly and create new thread */
	httpd->running = 1;
	httpd->joined = 0;
	THREAD_CREATE(httpd->thread, httpd_thread, httpd);
	MUTEX_UNLOCK(httpd->run_mutex);

	return 1;
}
示例#28
0
void *callback_server(void *ctx)
{
  WSDualHttpBinding_USCOREICalculatorDuplexService *callback = (WSDualHttpBinding_USCOREICalculatorDuplexService*)ctx;
  THREAD_TYPE tid;

  callback->soap->accept_timeout = 10; /* server quits after 10 seconds of inactivity */

  printf("\n**** Callback Server Running\n");

  while (soap_valid_socket(callback->accept()))
    THREAD_CREATE(&tid, (void*(*)(void*))callback_thread, (void*)callback->copy());

  printf("\n**** Callback Server Terminated\n");

  return NULL;
}
static void setup(void) {
    running = UA_Boolean_new();
    *running = true;
    config = UA_ServerConfig_new_default();
    config->maxPublishReqPerSession = 5;
    server = UA_Server_new(config);
    UA_Server_run_startup(server);
    addNewEventType();
    setupSelectClauses();
    THREAD_CREATE(server_thread, serverloop);

    client = UA_Client_new(UA_ClientConfig_default);
    UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
    ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
    setupSubscription();
}
void on_button_p1_next_clicked(GtkWidget* widget, gpointer data)
{
  /* First, disable the widget so it cannot be clicked again */
  gtk_widget_set_sensitive(widget, false);

  /* Make sure thread is joined */
  THREAD_JOIN(g_mainSearchThread);

  /* Reset state vars */
  g_dongleSearchStatus = DONGLE_SEARCHING;
  
  /* Start the main search thread */
  THREAD_CREATE(&g_mainSearchThread, findDongleThread, NULL);

  /* Start the search timeout */
  g_timeout_add(200, findDongleTimeout, NULL);
}