Beispiel #1
0
/**
 * @brief stop a connection
 * @param c the connection to stop
 */
void stop_connection(conn_node *c) {
  stop_children(c); // stop children and wait them to gracefully exits.
  close(c->fd); // stop the reader
  control_deactivate(&(c->control));
  control_deactivate(&(c->incoming.control));   // stop the worker
  control_deactivate(&(c->outcoming.control));  // stop the writer
}
static void
control_activate_cb (BonoboControl *control,
		     gboolean activate,
		     EYank *yank)
{
	BonoboUIComponent *ui_component;
	
	ui_component = bonobo_control_get_ui_component (control);
	
	if (yank->shell_view_interface == NULL) {
		Bonobo_ControlFrame control_frame;
		CORBA_Environment ev;

		control_frame = bonobo_control_get_control_frame (control);
		if (control_frame == NULL) {
			goto out;
		}

		CORBA_exception_init (&ev);
		yank->shell_view_interface = Bonobo_Unknown_queryInterface (control_frame, "IDL:GNOME/Evolution/ShellView:1.0", &ev);

		if (BONOBO_EX (&ev)) {
			g_warning ("Error getting ShellView. %s", CORBA_exception_id (&ev));
			yank->shell_view_interface = CORBA_OBJECT_NIL;
		}
		CORBA_exception_free (&ev);
	}
 out:

	if (activate)
		control_activate (control, ui_component, yank);
	else
		control_deactivate (control, ui_component, yank);
}
Beispiel #3
0
int main(void) {
    int x;
    wnode *mywork;
    initialize_structs();
    /* CREATION */

    if (create_threads()) {
        printf("Error starting threads... cleaning up.\n");
        join_threads();
        dabort();
    }
    pthread_mutex_lock(&wq.control.mutex);
    for (x=0; x<16000; x++) {
        mywork=malloc(sizeof(wnode));
        if (!mywork) {
            printf("ouch! can't malloc!\n");
            break;
        }
        mywork->jobnum=x;
        queue_put(&wq.work,(node *) mywork);
    }
    pthread_mutex_unlock(&wq.control.mutex);
    pthread_cond_broadcast(&wq.control.cond);
    printf("sleeping...\n");
    sleep(2);
    printf("deactivating work queue...\n");
    control_deactivate(&wq.control);
    /* CLEANUP  */
    join_threads();
    cleanup_structs();
}
Beispiel #4
0
/**
 * @brief stop the @reaper thread
 * @returns 0 on success, -1 on error
 */
int stop_reaper() {
  
  void *exit_val;
  
  if(!reaper_tid)
    return 0;
  
  if(control_deactivate(&(graveyard.control))) {
    print( ERROR, "cannot deactivate the graveyard" );
    return -1;
  }
  
  if(pthread_join(reaper_tid, &exit_val)) {
    print( ERROR, "pthread_join: %s", strerror(errno) );
    return -1;
  }
#ifdef NDEBUG
  else if(exit_val)
    print( WARNING, "reaper joined. (exit_val=%p)", exit_val );
#else
  else
    print( DEBUG, "reaper joined. (exit_val=%p)", exit_val );
#endif
  
  return 0;
}
Beispiel #5
0
/**
 * @brief stop the reader thread.
 * WARNING: ensure to shutdown ::sockfd before call this.
 */
void stop_reader() {
  if(reader_tid) {
    control_deactivate(&(incoming_messages.control));
    pthread_join(reader_tid, NULL);
    reader_tid = 0;
  }
}
Beispiel #6
0
void *reader(void *arg) {
  message *m;
  
  while((m = read_message(sockfd))) {
    if(enqueue_message(&(incoming_messages), m)) {
      LOGE("%s: cannot enqueue messages", __func__);
      dump_message(m);
      free_message(m);
      break;
    }
  }
  
  control_deactivate(&(incoming_messages.control));
  
  LOGI("%s: quitting", __func__);
  
  return 0;
}