Changeset 4328

Show
Ignore:
Timestamp:
01/28/91 10:57:00 (19 years ago)
Author:
raeburn
Message:

Renamed _losinghost to losinghost; added new & delete ops.
(De-/allocations changed.)
Explicit version of default initializer for losing_hosts removed.
NULLLH definition deleted.

Use access methods to get/set ZServerDesc_t::zs_state.
Use new/delete for ZHostList_t.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/athena/lib/zephyr/server/hostm.c

    r4078 r4328  
    1616#ifndef lint 
    1717#ifndef SABER 
    18 static char rcsid_hostm_c[] = "$Header: /afs/dev.mit.edu/source/repository/athena/lib/zephyr/server/hostm.c,v 1.33 1990-12-29 01:35:08 raeburn Exp $"; 
     18static char rcsid_hostm_c[] = "$Header: /afs/dev.mit.edu/source/repository/athena/lib/zephyr/server/hostm.c,v 1.34 1991-01-28 15:57:00 raeburn Exp $"; 
    1919#endif 
    2020#endif 
     
    7878        ZHostList_t *host;              /* ptr to host struct */ 
    7979        int server_index;               /* index of server in the table */ 
     80#if 0 /* always allocated in arrays */ 
     81#if !defined(__GNUG__) || defined(FIXED_GXX) 
     82        void *operator new (unsigned int sz) { return zalloc (sz); } 
     83        void operator delete (void *ptr) { zfree (ptr, sizeof (hostlist)); } 
     84#endif 
     85#endif 
    8086}; 
    8187 
    82 typedef struct _losinghost { 
    83         struct _losinghost *q_forw; 
    84         struct _losinghost *q_back; 
     88struct losinghost { 
     89        losinghost *q_forw; 
     90        losinghost *q_back; 
    8591        ZHostList_t *lh_host; 
    8692        timer lh_timer; 
    8793        ZClient_t *lh_client; 
    88 } losinghost; 
    89  
    90 #define NULLLH          ((struct _losinghost *) 0) 
     94#if !defined(__GNUG__) || defined(FIXED_GXX) 
     95        void *operator new (unsigned int sz) { return zalloc (sz); } 
     96        void operator delete (void *ptr) { zfree (ptr, sizeof (losinghost)); } 
     97#endif 
     98}; 
     99 
    91100#define NULLHLT         ((struct hostlist *) 0) 
    92101 
     
    96105static long lose_timo = LOSE_TIMO; 
    97106 
    98 static losinghost *losing_hosts = NULLLH; /* queue of pings for hosts we 
     107static losinghost *losing_hosts; /* queue of pings for hosts we 
    99108                                             doubt are really there */ 
    100109 
     
    113122/*ARGSUSED*/ 
    114123Code_t 
    115 hostm_dispatch(ZNotice_t *notice, int auth, struct sockaddr_in *who, ZServerDesc_t *server) 
     124hostm_dispatch(ZNotice_t *notice, int auth, struct sockaddr_in *who, 
     125               ZServerDesc_t *server) 
    116126{ 
    117127        ZServerDesc_t *owner; 
     
    239249                                timer_reset(lhp->lh_timer); 
    240250                                xremque(lhp); 
    241                                 xfree(lhp); 
     251                                delete lhp; 
    242252                                lhp = lhp2->q_forw; 
    243253                        } else 
     
    280290        for (i = 0; i < nservers; i++){ 
    281291                if (i == me_server_idx) continue; 
    282                 if (otherservers[i].zs_state == SERV_UP) 
     292                if (otherservers[i].state() == SERV_UP) 
    283293                        break; 
    284294        } 
     
    297307                                newserver = (int) (random() % (nservers - 1)) + 1; 
    298308                        while (newserver == limbo_server_idx() || 
    299                                (otherservers[newserver].zs_state != SERV_UP && 
    300                                 otherservers[newserver].zs_state != SERV_TARDY) || 
     309                               (otherservers[newserver].state() != SERV_UP && 
     310                                otherservers[newserver].state() != SERV_TARDY) || 
    301311                               newserver == me_server_idx); 
    302312                        hostm_deathgram(&host->zh_addr, &otherservers[newserver]); 
     
    322332#endif 
    323333        if (!losing_hosts) { 
    324                 if (!(losing_hosts = (losinghost *) xmalloc(sizeof(losinghost)))) { 
     334                losing_hosts = new losinghost; 
     335                if (!losing_hosts) { 
    325336                        syslog(LOG_ERR, "no mem losing host"); 
    326337                        return; 
     
    337348                        return; 
    338349                } 
    339         if (!(newhost = (losinghost *) xmalloc(sizeof(losinghost)))) { 
     350        newhost = new losinghost; 
     351        if (!newhost) { 
    340352                syslog(LOG_ERR, "no mem losing host 2"); 
    341353                return; 
     
    378390#endif 
    379391                xremque(which); 
    380                 xfree(which); 
     392                delete which; 
    381393                (void) sigsetmask(omask); 
    382394                return; 
     
    414426        server_forward(&notice, 0, &who); /* unauthentic */ 
    415427 
    416         xfree(which); 
     428        delete which; 
    417429        (void) sigsetmask(omask); 
    418430        return; 
     
    452464                        server_kill_clt(lhp->lh_client); 
    453465                        xremque(lhp); 
    454                         xfree(lhp); 
     466                        delete lhp; 
    455467                        /* now that the remque adjusted the linked list, 
    456468                           we go forward again */ 
     
    489501#endif 
    490502                        xremque(lhp); 
    491                         xfree(lhp); 
     503                        delete lhp; 
    492504                        /* now that the remque adjusted the linked list, 
    493505                           we go forward again */ 
     
    546558 
    547559        /* allocate a header */ 
    548         if (!(hlist = (ZHostList_t *)xmalloc(sizeof(ZHostList_t)))) { 
    549                 syslog(LOG_WARNING, "hm_attach malloc"); 
     560        hlist = new ZHostList_t; 
     561        if (!hlist) { 
     562                syslog(LOG_WARNING, "hm_attach alloc"); 
    550563                (void) sigsetmask(omask); 
    551564                return(ENOMEM); 
     
    553566        /* set up */ 
    554567        if (!(clist = (ZClientList_t *)xmalloc(sizeof(ZClientList_t)))) { 
    555                 xfree(hlist); 
     568                delete hlist; 
    556569                (void) sigsetmask(omask); 
    557570                return(ENOMEM); 
     
    601614        remove_host(host); 
    602615 
    603         xfree(host); 
     616        delete host; 
    604617        (void) sigsetmask(omask); 
    605618        return; 
     
    903916                zdbug((LOG_DEBUG,"last host")); 
    904917#endif 
    905                 xfree(all_hosts); 
     918                xfree (all_hosts); 
    906919                all_hosts = NULLHLT; 
    907920                (void) sigsetmask(omask); 
     
    929942                i++; 
    930943        } 
    931         xfree(oldlist); 
     944        xfree (oldlist); 
    932945        (void) sigsetmask(omask); 
    933946        return;