void m_unlink(void) { int rta; char * sem; sem = get_sem_name(); printf("A ejecutar: sem_unlink(%s);\n", sem); rta = sem_unlink(sem); if ( rta == -1 ) printf("Error al hacer close, errno = %d (%s)\n", errno, strerror(errno)); putchar('\n'); }
/** * Set up the DPDK rings which will be used to pass packets, via * pointers, between the multi-process server and client processes. * Each client needs one RX queue. */ static int init_shm_rings(void) { unsigned i; unsigned socket_id; const char * q_name; #ifdef INTERRUPT_FIFO const char * fifo_name; #endif #ifdef INTERRUPT_SEM const char * sem_name; sem_t *mutex; #endif #if defined(INTERRUPT_FIFO) || defined(INTERRUPT_SEM) #ifdef DPDK_FLAG const char *irq_flag_name; const unsigned flagsize = 4; #else key_t key; int shmid; char *shm; #endif #endif const unsigned ringsize = CLIENT_QUEUE_RINGSIZE; clients = rte_malloc("client details", sizeof(*clients) * num_clients, 0); if (clients == NULL) rte_exit(EXIT_FAILURE, "Cannot allocate memory for client program details\n"); for (i = 0; i < num_clients; i++) { /* Create an RX queue for each client */ socket_id = rte_socket_id(); q_name = get_rx_queue_name(i); clients[i].rx_q = rte_ring_create(q_name, ringsize, socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ ); /* single prod, single cons */ //verify two functions uint16_t ring_cur_entries = rte_ring_count(clients[i].rx_q); uint16_t ring_free_entries = rte_ring_free_count(clients[i].rx_q); fprintf(stderr, "ring_cur_entries=%d, ring_free_entries=%d\n", ring_cur_entries, ring_free_entries); if (clients[i].rx_q == NULL) rte_exit(EXIT_FAILURE, "Cannot create rx ring queue for client %u\n", i); //add by wei, create FIFO pipe #ifdef INTERRUPT_FIFO umask(0); fifo_name = get_fifo_name(i); clients[i].fifo_name = fifo_name; mknod(fifo_name, S_IFIFO|0666, 0); clients[i].fifo_fp = fopen(fifo_name, "w"); if(clients[i].fifo_fp == NULL) { fprintf(stderr, "can not create FIFO for client %d\n", i); exit(1); } #endif #ifdef INTERRUPT_SEM sem_name = get_sem_name(i); clients[i].sem_name = sem_name; fprintf(stderr, "sem_name=%s for client %d\n", sem_name, i); mutex = sem_open(sem_name, O_CREAT, 06666, 0); if(mutex == SEM_FAILED) { fprintf(stderr, "can not create semaphore for client %d\n", i); sem_unlink(sem_name); exit(1); } clients[i].mutex = mutex; #endif #if defined(INTERRUPT_FIFO) || defined(INTERRUPT_SEM) #ifdef DPDK_FLAG irq_flag_name = get_irq_flag_name(i); clients[i].irq_flag = (int *)rte_ring_create(irq_flag_name, flagsize, socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ ); /* single prod, single cons */ #else key = get_rx_shmkey(i); if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) { fprintf(stderr, "can not create the shared memory segment for client %d\n", i); exit(1); } if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) { fprintf(stderr, "can not attach the shared segment to the server space for client %d\n", i); exit(1); } clients[i].shm_server = (int *)shm; #endif #endif } return 0; }
int examine_document (xmlNode * node) { /*Examine the parse tree, add semantic attributes and set indicators.*/ xmlNode *child; logMessage(LOG_INFO, "Begin examine_document: node->name=%s", node->name); if (node == NULL) return 0; ud->stack[++ud->top] = set_sem_attr (node); if (ud->format_for == utd) { unsigned char *name = get_sem_name (node); if (name[0] != 0) xmlNewProp (node, (xmlChar *)"semantics", (xmlChar *)name); } switch (ud->stack[ud->top]) { case skip: pop_sem_stack (); return 1; case configfile: doConfigfile (node); break; case configstring: do_configstring (node); break; case code: ud->has_comp_code = 1; break; case contentsheader: ud->has_contentsheader = 1; break; case math: ud->has_math = 1; break; case chemistry: ud->has_chem = 1; break; case graphic: ud->has_graphics = 1; break; case music: ud->has_music = 1; break; default: break; } child = node->children; while (child) { switch (child->type) { case XML_ELEMENT_NODE: examine_document (child); break; case XML_TEXT_NODE: examText (child); break; case XML_CDATA_SECTION_NODE: examCdataa (child); examine_document (child); break; default: break; } child = child->next; } ud->top--; return 1; }