int decode_task() { OutputBuffer * cb = &(getPlayerData()->buffer); PlayerControl * pc = &(getPlayerData()->playerControl); DecoderControl * dc = &(getPlayerData()->decoderControl); unblockSignals(); mpm_enter(MPM_DECODE); fprintf(stderr,"0 In the decode_task:\r\n"); /* CHILD TASK */ while(1) { if(dc->cycleLogFiles) { myfprintfCloseAndOpenLogFile(); dc->cycleLogFiles = 0; } else if(dc->start || dc->seek) { fprintf(stderr,"CAlling decodestart func :\r\n"); decodeStart(pc, cb, dc); } else if(dc->stop) { dc->state = DECODE_STATE_STOP; dc->stop = 0; } else{ my_usleep(10000); // fprintf(stderr,"in the decode_task sleep:\r\n"); } } return EXIT_SUCCESS; /* END OF CHILD TASK */ }
bool CTreeViewGames::on_button_press_event(GdkEventButton* p_event) { Gtk::TreeModel::iterator l_iter; Glib::RefPtr<Gtk::TreeSelection> l_selection; Gtk::TreeView::on_button_press_event(p_event); if((p_event->type == GDK_BUTTON_PRESS) && (p_event->button == 3) ) { // Actualizamos el menú dependiendo de la selección l_selection = this->get_selection(); l_iter = l_selection->get_selected(); if(l_iter) { blockSignals(); m_action_playgame->set_sensitive(true); m_action_favorite->set_sensitive(true); m_action_favorite->set_active((*l_iter)[m_columns.m_favorite]); m_action_played->set_sensitive(true); m_action_played->set_active((*l_iter)[m_columns.m_flags] & 0x08); m_action_working->set_sensitive(true); m_action_working->set_active((*l_iter)[m_columns.m_flags] & 0x04); m_action_rank->set_sensitive(true); m_action_ranks[(*l_iter)[m_columns.m_rank]]->set_active(true); m_action_remove->set_sensitive(true); unblockSignals(); } else { blockSignals(); m_action_playgame->set_sensitive(false); m_action_favorite->set_sensitive(false); m_action_favorite->set_active(false); m_action_played->set_sensitive(false); m_action_played->set_active(false); m_action_working->set_sensitive(false); m_action_working->set_active(false); m_action_rank->set_sensitive(false); m_action_remove->set_sensitive(false); unblockSignals(); } m_gamelist_popup->popup(p_event->button, p_event->time); return true; } else if((p_event->type == GDK_2BUTTON_PRESS) && (p_event->button == 1) ) { playGame(); return true; } else return false; }
/************************************************************** * * semOpen - Open a semaphore. * * This routine attempts to: * 1. Opens a System V semaphore that already exist. * 2. If 1. fails then the semaphore is created. * * * RETURNS: * semaphore ID, else -1 * * Author Greg Brissey 6/24/94 */ int semOpen(key_t key, int initval) /* key_t key - key to semaphore */ /* int initval - initial value of semaphore if it needs to be created */ { int id; sigset_t signalMask; /* printf("semOpen\n"); */ if ( (key == IPC_PRIVATE) || (key == (key_t) -1) ) { errLogRet(ErrLogOp,debugInfo,"semOpen: Invalid Key(%d) given.\n",key); return(-1); /* not for private sems or invalid key */ } blockSignals(&signalMask); /* block signals while working on the semaphores */ if ( (id = semget(key, 3, 0)) < 0) { /* printf("semOpen: calling semCreate(%d,%d)\n",key,initval); */ /* semCreate also decrements Process count. */ if ( (id = semCreate(key, initval)) < 0) { unblockSignals(&signalMask); return(-1); /* doesn't exist or kernel table full */ } } else { /* Decrement Process count. No Need to lock */ if (semop(id, &semOpenOps[0], 1) < 0) { errLogSysRet(ErrLogOp,debugInfo,"semOpen: semid: %d semop error",id); unblockSignals(&signalMask); return(-1); } } DPRINT1(1,"semOpen: SEMID: %d\n",id); unblockSignals(&signalMask); return(id); }
/************************************************************** * * semGive - Give a semaphore back. * * This routine gives a System V semaphore back. * * * RETURNS: * VOID * * Author Greg Brissey 6/24/94 */ void semGive(int id) /* int id - semaphore id */ { sigset_t signalMask; blockSignals(&signalMask); /* block signals while working on the semaphores */ sem_op(id, 1); unblockSignals(&signalMask); return; }
int decoderInit(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) { int rc; blockSignals(); rc = mpm_spawn(MPM_DECODE,NULL); unblockSignals(); if (rc<=0) { ERROR("return code from mpm_spawn(): %d\n",rc); strncpy(pc->erroredUrl, pc->utf8url, MAXPATHLEN); pc->erroredUrl[MAXPATHLEN] = '\0'; pc->error = PLAYER_ERROR_SYSTEM; return -1; } return 0; }
/************************************************************** * * semClose - Close a semaphore. * * This routine closes a System V semaphore that already exist. *This is the normal routine used by an application to close the *a semaphore that it is done with or prior to exiting. * * * RETURNS: * VOID * * Author Greg Brissey 6/24/94 */ void semClose(int id) /* int id - Semaphore ID */ { int semval; sigset_t signalMask; blockSignals(&signalMask); /* First Obtain Race Lock */ if (semop(id, &semCloseOps[0], 3) < 0) { errLogSysRet(ErrLogOp,debugInfo, "semClose: semid: %d, semop() can't get lock",id); } /* if last process to be using semaphore then remove it, else decrement the process count */ if ( (semval = semctl(id, PROC_CNT, GETVAL, 0)) < 0) { errLogSysRet(ErrLogOp,debugInfo, "semClose: semid: %d, semctl() can't GETVAL on PROC_CNT",id); } if (semval > INITCOUNT) { errLogRet(ErrLogOp,debugInfo,"semClose: PROC_CNT greater than initial value"); } else if (semval == INITCOUNT) { DPRINT1(1,"semClose: delete semaphore: %d\n",id); semDelete(id); } else { DPRINT1(1,"semClose: just decrement process count for semaphore: %d\n",id); if (semop(id, &semUnlockOps[0], 1) < 0) errLogSysRet(ErrLogOp,debugInfo, "semClose: semid: %d, semop() can't Unlock",id); } unblockSignals(&signalMask); }
int semCreate(key_t key, int initval) /* key_t key - key to semaphore */ /* int initval - initial value of semaphore */ { register int id, semvalue; sigset_t signalMask; union semun { int val; struct semid_ds *buf; ushort *array; } semctl_arg; if ( (key == IPC_PRIVATE) || (key == (key_t) -1) ) { errLogRet(ErrLogOp,debugInfo,"semCreate: Invalid Key given.\n"); return(-1); /* not for private sems or invalid key */ } blockSignals(&signalMask); /* block signals while working on the semaphores */ makeitagain: if ( (id = semget(key, 3, (SEM_ALL_PERM | IPC_CREAT))) < 0) { errLogSysRet(ErrLogOp,debugInfo,"semCreate: semget() error"); unblockSignals(&signalMask); return(-1); /* permission problem or kernel table full */ } /* grab sempore and apply race lock to avoid race conditions */ if (semop(id, &semLockOps[0], 2) < 0) { /* some one deleted before we could lock it, make it again Sam */ if (errno == EINVAL) goto makeitagain; errLogSysRet(ErrLogOp,debugInfo, "semCreate: semid: semop() can't take locking semaphore"); semctl(id, 0, IPC_RMID, 0); unblockSignals(&signalMask); return(-1); } if ( (semvalue = semctl(id, 1, GETVAL, 0)) < 0 ) { errLogSysRet(ErrLogOp,debugInfo,"semCreate: semid: %d, semctl() can't GETVAL:", id); semctl(id, 0, IPC_RMID, 0); unblockSignals(&signalMask); return(-1); } if (semvalue == 0) /* 1st time so initialize values */ { semctl_arg.val = initval; if (semctl(id, SEMVALUE, SETVAL, semctl_arg) < 0) { errLogSysRet(ErrLogOp,debugInfo, "semCreate: semid: %d, semctl() can't SETVAL to SEMVALUE", id); semctl(id, 0, IPC_RMID, 0); unblockSignals(&signalMask); return(-1); } semctl_arg.val = INITCOUNT; if (semctl(id, PROC_CNT, SETVAL, semctl_arg) < 0) { errLogSysRet(ErrLogOp,debugInfo, "semCreate: semid: %d, semctl() can't SETVAL to PROC_CNT", id); semctl(id, 0, IPC_RMID, 0); unblockSignals(&signalMask); return(-1); } } /* Decrement Process Counter and release Race Lock */ if (semop(id, &semFinCreatOps[0], 2) < 0) { errLogSysRet(ErrLogOp,debugInfo, "semCreate: semid: %d, semctl() can't finish create", id); semctl(id, 0, IPC_RMID, 0); unblockSignals(&signalMask); return(-1); } semDbmAdd(id); unblockSignals(&signalMask); return(id); }