list_t* find_and_report(const char* datafile, const char mode, int pkgc, list_t* argv) { // set quiet to avoid print results of search_record() unsigned short int hold_quiet=quiet; quiet = 1; int i=0; int found = 0; unsigned short int fcount = 0; unsigned short int mcount = 0; list_t* founded = new_list(0); list_t* missing = new_list(0); for (i=0; i<pkgc; i++) { char* pkg = get_list(argv,i); char buf[1024]; strcpy(buf, pkg); char* tk = strtok(buf, "|"); while(tk != NULL) { found = 0; if(search_record(datafile, tk)) { found = 1; break; } tk = strtok(NULL, " ,"); } if(found == 1) { fcount = fcount+1; resize_list(founded,fcount); add_list(founded,fcount-1,tk); } else { mcount = mcount+1; resize_list(missing,mcount); add_list(missing,mcount-1,pkg); } } quiet = hold_quiet; switch(mode) { case 'f' : return(founded); case 'm' : return(missing); } destroy_list(founded); destroy_list(missing); return(NULL); }
/* wait() takes the lock before and after wait (not during). In 7.2, shifting or resizing the list requires a PollGuard, but in 7.3, the underlying wakeupHandler will only touch the array during wait() so no lock is needed. */ int NdbWaitGroup::wait(Uint32 timeout_millis, int pct_ready) { int nready, nwait; m_active_version = 2; assert(pct_ready >=0 && pct_ready <= 100); lock(); /* Resize list if full */ if(unlikely(m_pos_new == m_array_size)) { resize_list(); } /* On last pop, if list has advanced past return point, shift back to 0 */ if(m_pos_ready && /* Not at zero */ m_pos_ready == m_pos_wait && /* Cannot currently pop */ m_pos_new > m_pos_return) /* NC > RETURNPOINT */ { for(Uint32 i = m_pos_wait; i < m_pos_new; i++) { m_array[i - m_pos_wait] = m_array[i]; } m_pos_new -= m_pos_wait; m_pos_ready = m_pos_wait = 0; } /* Number of items to wait for */ nwait = m_pos_new - m_pos_wait; unlock(); /********** ENTER WAIT **********/ int min_ndbs = nwait * pct_ready / 100 ; if(min_ndbs == 0 && pct_ready > 0) min_ndbs = 1; Ndb ** arrayHead = m_array + m_pos_wait; m_multiWaitHandler->waitForInput(arrayHead, nwait, min_ndbs, timeout_millis, &nready); /********** EXIT WAIT *********/ lock(); m_pos_wait += nready; unlock(); return nready; }