void chldcb_check () { for (;;) { int status; pid_t pid = waitpid (-1, &status, WNOHANG); if (pid == 0 || pid == -1) break; if (child *c = chldcbs[pid]) { chldcbs.remove (c); #ifdef WRAP_DEBUG if (callback_trace & CBTR_CHLD) warn ("CALLBACK_TRACE: %schild pid %d (status %d) %s <- %s\n", timestring (), pid, status, c->cb->dest, c->cb->line); #endif /* WRAP_DEBUG */ STOP_ACHECK_TIMER (); sfs_leave_sel_loop (); (*c->cb) (status); START_ACHECK_TIMER (); delete c; } else if (sfs_core::g_zombie_collect) { zombie_t *z = zombies[pid]; if (z) { z->_status = status; } else { zombies.insert (New zombie_t (pid, status)); } } } }
void update () { if (simulated_input) return; f_node *n = nodes.first (); while (n) { update (n); n = nodes.next (n); } }
void update_highlighted () { if (simulated_input) return; f_node *n = nodes.first (); while (n) { if (n->highlight) update (n); n = nodes.next (n); } }
afsdirentry::afsdirentry (afsdir *dir, const str &name, afsnode *node) : dir (dir), name (name), node (mkref (node)), cookie (gencookie ()) { node->addlink (); cookietab.insert (this); dir->entries.insert (this); }
f_node * add_node (const chord_node &n) { f_node *nu = nodes[n.x]; if (!nu) { warn << "added " << n << "\n"; nu = New f_node (n); nodes.insert (nu); char nodess[1024]; sprintf (nodess, "%zd nodes", nodes.size ()); gtk_label_set_text (GTK_LABEL (total_nodes), nodess); } get_queue.push_back (n.x); return nu; }
void closesim::fhfree (fhtimer *fht) { assert (fht->serv == this); fq->timeq.remove (fht); fhtab.remove (fht); fq->minopen++; delete fht; }
void chldcb (pid_t pid, cbi::ptr cb) { if (child *c = chldcbs[pid]) { chldcbs.remove (c); delete c; } zombie_t *z; if ((z = zombies[pid])) { int s = z->_status; zombies.remove (z); delete z; if (cb) (*cb) (s); } else if (cb) { chldcbs.insert (New child (pid, cb)); } }
void nodelete_remptr (const void *obj, const char *fl, int *fp) { if (do_nodelete ()) for (objref *oref = objreftab[obj]; oref; oref = objreftab.nextkeq (oref)) if (oref->refline == fl && oref->flagp == fp) { delete oref; return; } }
static inline rpcstats * getstats (int progno, int procno) { str key = strbuf ("%d:%d", progno, procno); rpcstats *stats = rpc_stats_tab[key]; if (!stats) { stats = New rpcstats (key); rpc_stats_tab.insert (stats); } return stats; }
fhtimer * closesim::fhalloc (const nfs_fh3 &fh) { fhtimer *fht = New fhtimer (this, fh); fht->expire = sfs_get_timenow() + closesim_minlife; fq->minopen--; fq->timeq.insert (fht); fhtab.insert (fht); fq->fhclean (); return fht; }
inline void nodelete_check (const void *ptr) { if (do_nodelete ()) for (objref *oref = objreftab[ptr]; oref; oref = objreftab.nextkeq (oref)) { if (oref->flagp) (*oref->flagp)++; else panic ("deleting ptr %p still referenced from %s\n", ptr, oref->refline); } }
void get_cb (chordID next) { draw_ring (); if (get_queue.size ()) { chordID n = get_queue.pop_front (); f_node *nu = nodes[n]; if (nu) update (nu); } else { f_node *node_next = nodes[next]; if (node_next == NULL) node_next = nodes.first (); if (node_next) { update (node_next); node_next = nodes.next (node_next); if (node_next == NULL) node_next = nodes.first (); next = node_next->ID; } // else no nodes, keep calling get_cb until there are some } delaycb (0, 1000*1000*interval, wrap (&get_cb, next)); }
client::client (ref<axprt_crypt> x) : sfsserv (x), fsrv (NULL), generation (nextgen ()) { nfssrv = asrv::alloc (x, ex_nfs_program_3, wrap (mkref (this), &client::nfs3pre_acl_dispatch)); nfscbc = aclnt::alloc (x, ex_nfscb_program_3); char sfs_owner[] = SFSOWNER; struct passwd *pw = getpwnam (sfs_owner); int u_sfs = pw->pw_uid; int g_sfs = pw->pw_gid; int g_sock = pw->pw_gid; //fixme: put something different! int g_fifo = pw->pw_gid; //likewise auth_sfs = authunix_create ("localhost", u_sfs, g_sfs, 0, NULL); auth_sfssock = authunix_create ("localhost", u_sfs, g_sock, 0, NULL); auth_sfsfifo = authunix_create ("localhost", u_sfs, g_fifo, 0, NULL); clienttab.insert (this); }
void mget_state_t::load_batches (const dsdc_hash_ring_t &r) { for (u_int i = 0; i < n; i++) { dsdc_key_t k = (*keys)[i]; dsdc_ring_node_t *n = r.successor (k); (*res)[i].key = k; if (!n) { (*res)[i].res.set_status (DSDC_NONODE); } else { ptr<aclnt_wrap_t> w = n->get_aclnt_wrap (); mget_batch_t *batch; str id = w->remote_peer_id (); if (!(batch = batches[id])) { batch = New mget_batch_t (id, w, mkref (this)); batches.insert (batch); } batch->arg.push_back (k); batch->positions.push_back (i); } } }
void mget_state_t::dispatch_slaves () { batches.traverse (wrap (this, &mget_state_t::dispatch_slave)); }
inline bool do_nodelete () { return do_nodelete_flag > 0 && !nodelete_ignore_count && !globaldestruction && objreftab.constructed (); }
inline objref::~objref () { objreftab.remove (this); }
inline objref::objref (const void *o, const char *fl, int *fp) : obj (o), refline (fl), flagp (fp) { objreftab.insert (this); }
client::~client () { clienttab.remove (this); }
afsdirentry::~afsdirentry () { node->remlink (); dir->entries.remove (this); cookietab.remove (this); }
sfssrv_exec::~sfssrv_exec () { exectab.remove (this); }
sfssrv_exec::sfssrv_exec (const vec<str> &av) : argv (av) { assert (!argv.empty ()); exectab.insert (this); }