Пример #1
0
/* delete a vis client. don't use this method without mutex! */
void
delete_client (int32_t id)
{
	xmms_vis_client_t *c;

	if (id < 0 || id >= vis->clientc) {
		return;
	}

	c = vis->clientv[id];
	if (c == NULL) {
		return;
	}

	if (c->type == VIS_UNIXSHM) {
		cleanup_shm (&c->transport.shm);
	} else if (c->type == VIS_UDP) {
		cleanup_udp (&c->transport.udp, vis->socket);
	}

	g_free (c);
	vis->clientv[id] = NULL;

	xmms_log_info ("Removed visualization client %d", id);
}
Пример #2
0
int main(int argc, char **argv){
   char c;
   char *cores = NULL;
   char *nodes = NULL;
   int shuffle = 0;
   struct shared_state s = {};

   while ((c = getopt(argc, argv, "+vVsc:n:SN")) != -1) {
      switch (c) {
         case 'c':
            if(cores) {
               fprintf(stderr, "-c or -n already used !\n");
               exit(EXIT_FAILURE);
            }

            cores = strdup(optarg);
            break;
         case 'n':
            if(nodes || cores) {
               fprintf(stderr, "-c or -n already used !\n");
               exit(EXIT_FAILURE);
            }

            nodes = strdup(optarg);
            break;
         case 'N':
            s.per_node = 1;
            break;
         case 's':
            shuffle = 1;
            break;
         case 'S':
            s.server = 1;
            break;
         case 'v':
            s.verbose = 1;
            break;
         case 'V':
            s.verbose = 1;
            s.verbose_err = 1;
            break;
         default:
            usage(argv[0]);
      }
   }

   if(!cores && !nodes)
      cores = build_default_affinity_string(shuffle);

   if(optind == argc)
      usage(argv[0]);
   argv +=  optind;

   char *lib = get_lib_path();
   setenv("LD_PRELOAD", lib, 1);
   free(lib);

   int *cores_array;
   if(cores) {
      parse_cores(cores, &cores_array, &s.nr_entries_in_cores, 0);
   } else {
      parse_cores(nodes, &cores_array, &s.nr_entries_in_cores, 1);
   }

   char *uniq_shm_name = NULL;
   assert(asprintf(&uniq_shm_name, "%s_%d", "/tmp/shm", gettid()));
   assert(create_shm(uniq_shm_name, &s, cores_array));
   setenv("PINTHREADS_SHMID", uniq_shm_name, 1);
   setenv("PINTHREADS_SHMSIZE", get_shm_size(), 1);
   free(uniq_shm_name);


   execvp(argv[0], argv);
   perror("execvp");
   fprintf(stderr,"failed to execute %s\n", argv[0]);

   cleanup_shm(uniq_shm_name);

   return EXIT_SUCCESS;
}
static void log_and_cleanup(char *msg, apr_status_t status, server_rec *s)
{
    ap_log_error(APLOG_MARK, APLOG_ERR, status, s, "Error: %s", msg);
    cleanup_shm(NULL);
}