~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to snmplib/callback.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-12-08 14:59:50 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071208145950-u1tykhpw56nyzqik
Tags: 5.4.1~dfsg-4ubuntu1
* Merge from debian unstable.
* Remaining Ubuntu changes:
  - Remove stop links from rc0 and rc6
  - Munge Maintainer field as per spec.
* Ubuntu changes dropped:
  - Symlink common files between the packages, CDBS ought to handle that
    for us automatically.
* The latest Debian changes has dropped history from the changelog. Slot in
  the Ubuntu changes as best I can. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
 * has been evaluated for use in a multi-threaded environment.
89
89
 * In 5.2, it was a single lock. For 5.3, it has been updated to
90
90
 * a lock per callback, since a particular callback may trigger
91
 
 * registration/unregistartion of other callbacks (eg AgentX
 
91
 * registration/unregistration of other callbacks (eg AgentX
92
92
 * subagents do this).
93
93
 */
94
94
#define LOCK_PER_CALLBACK_SUBID 1
96
96
static int _locks[MAX_CALLBACK_IDS][MAX_CALLBACK_SUBIDS];
97
97
#define CALLBACK_LOCK(maj,min) ++_locks[major][minor]
98
98
#define CALLBACK_UNLOCK(maj,min) --_locks[major][minor]
 
99
#define CALLBACK_LOCK_COUNT(maj,min) _locks[major][minor]
99
100
#else
100
101
static int _lock;
101
102
#define CALLBACK_LOCK(maj,min) ++_lock
102
103
#define CALLBACK_UNLOCK(maj,min) --_lock
 
104
#define CALLBACK_LOCK_COUNT(maj,min) _lock
103
105
#endif
104
106
 
105
107
NETSNMP_STATIC_INLINE int
123
125
            snmp_log(LOG_WARNING,
124
126
                     "_callback_lock already locket in %s\n", warn);
125
127
        if (assert)
126
 
            netsnmp_assert(1==_locks[major][minor]);
 
128
            netsnmp_assert(1==CALLBACK_LOCK_COUNT(major,minor));
127
129
        
128
130
        return 1;
129
131
    }
169
171
    _callback_need_init = 0;
170
172
    
171
173
    memset(thecallbacks, 0, sizeof(thecallbacks)); 
 
174
#ifdef LOCK_PER_CALLBACK_SUBID
172
175
    memset(_locks, 0, sizeof(_locks));
 
176
#else
 
177
    _lock = 0;
 
178
#endif
173
179
    
174
180
    DEBUGMSGTL(("callback", "initialized\n"));
175
181
}
425
431
            (!matchargs || (scp->sc_client_arg == arg))) {
426
432
            DEBUGMSGTL(("callback", "unregistering (%d,%d) at %p\n", major,
427
433
                        minor, scp));
428
 
            if(1 == _locks[major][minor]) {
 
434
            if(1 == CALLBACK_LOCK_COUNT(major,minor)) {
429
435
                *prevNext = scp->next;
430
436
                SNMP_FREE(scp);
431
437
                scp = *prevNext;