1535
1540
netsnmp_remove_delegated_requests_for_session(netsnmp_session *sess)
1537
1542
netsnmp_agent_session *asp;
1543
int total_count = 0;
1540
1545
for (asp = agent_delegated_list; asp; asp = asp->next) {
1542
1547
* check each request
1544
1551
netsnmp_request_info *request;
1545
for(request = asp->requests; request; request = request->next) {
1549
netsnmp_assert(NULL!=request->subtree);
1550
if(request->subtree->session != sess)
1552
for (i = 0; i <= asp->treecache_num; i++) {
1553
for (request = asp->treecache[i].requests_begin; request;
1554
request = request->next) {
1558
netsnmp_assert(NULL!=request->subtree);
1559
if(request->subtree->session != sess)
1554
* matched! mark request as done
1556
netsnmp_request_set_error(request, SNMP_ERR_GENERR);
1563
* matched! mark request as done
1565
netsnmp_request_set_error(request, SNMP_ERR_GENERR);
1570
agent_snmp_session_mark_cancelled(asp);
1571
total_count += count;
1562
1576
* if we found any, that request may be finished now
1565
1579
DEBUGMSGTL(("snmp_agent", "removed %d delegated request(s) for session "
1566
"%8p\n", count, sess));
1567
netsnmp_check_outstanding_agent_requests();
1580
"%8p\n", total_count, sess));
1581
netsnmp_check_delegated_requests();
2739
2753
return final_status;
2743
* loop through our sessions known delegated sessions and check to see
2744
* if they've completed yet. If there are no more delegated sessions,
2745
* check for and process any queued requests
2748
netsnmp_check_outstanding_agent_requests(void)
2757
netsnmp_check_delegated_requests(void)
2750
2759
netsnmp_agent_session *asp, *prev_asp = NULL, *next_asp = NULL;
2753
* deal with delegated requests
2755
2761
for (asp = agent_delegated_list; asp; asp = next_asp) {
2756
2762
next_asp = asp->next; /* save in case we clean up asp */
2757
2763
if (!netsnmp_check_for_delegated(asp)) {
2790
2796
prev_asp = asp;
2802
* loop through our sessions known delegated sessions and check to see
2803
* if they've completed yet. If there are no more delegated sessions,
2804
* check for and process any queued requests
2807
netsnmp_check_outstanding_agent_requests(void)
2809
netsnmp_agent_session *asp;
2812
* deal with delegated requests
2814
netsnmp_check_delegated_requests();
2795
2817
* if we are processing a set and there are more delegated
2820
2842
netsnmp_processing_set = netsnmp_agent_queued_list;
2821
2843
DEBUGMSGTL(("snmp_agent", "SET request remains queued while "
2822
"delegated requests finish, asp = %8p\n", asp));
2844
"delegated requests finish, asp = %8p\n",
2845
agent_delegated_list));
2825
2848
#endif /* NETSNMP_NO_WRITE_SUPPORT */
2880
2903
case SNMP_MSG_GETBULK:
2881
2904
case SNMP_MSG_GETNEXT:
2882
2905
netsnmp_check_all_requests_status(asp, 0);
2906
if (agent_snmp_session_is_cancelled(asp)) {
2907
DEBUGMSGTL(("snmp_agent","canceling next walk for asp %p\n", asp));
2883
2910
handle_getnext_loop(asp);
2884
2911
if (netsnmp_check_for_delegated(asp) &&
2885
2912
netsnmp_check_transaction_id(asp->pdu->transid) !=
3837
3864
#endif /* NETSNMP_FEATURE_REMOVE_SET_ALL_REQUESTS_ERROR */
3869
* Ugly hack to fix bug #950602 and preserve ABI
3870
* (the official patch adds netsnmp_agent_session->flags).
3871
* We must create parallel database of netsnmp_agent_sessions
3872
* and put cancelled requests there instead of marking
3873
* netsnmp_agent_session->flags.
3875
static netsnmp_agent_session **cancelled_agent_snmp_sessions;
3876
static int cancelled_agent_snmp_sessions_count;
3877
static int cancelled_agent_snmp_sessions_max;
3880
agent_snmp_session_mark_cancelled(netsnmp_agent_session *session)
3882
DEBUGMSGTL(("agent:cancelled", "Cancelling session %p\n", session));
3885
if (cancelled_agent_snmp_sessions_count + 1 > cancelled_agent_snmp_sessions_max) {
3886
netsnmp_agent_session **aux;
3887
int max = cancelled_agent_snmp_sessions_max + 10;
3888
aux = realloc(cancelled_agent_snmp_sessions, sizeof(netsnmp_agent_session*) * max);
3890
return SNMP_ERR_GENERR;
3891
cancelled_agent_snmp_sessions = aux;
3892
cancelled_agent_snmp_sessions_max = max;
3894
cancelled_agent_snmp_sessions[cancelled_agent_snmp_sessions_count] = session;
3895
cancelled_agent_snmp_sessions_count++;
3900
agent_snmp_session_is_cancelled(netsnmp_agent_session *session)
3903
for (i=0; i<cancelled_agent_snmp_sessions_count; i++)
3904
if (cancelled_agent_snmp_sessions[i] == session) {
3905
DEBUGMSGTL(("agent:cancelled", "session %p is cancelled\n", session));
3912
agent_snmp_session_release_cancelled(netsnmp_agent_session *session)
3919
DEBUGMSGTL(("agent:cancelled", "Removing session %p\n", session));
3921
/* delete the session from cancelled_agent_snmp_sessions */
3922
for (i=0, j=0; j<cancelled_agent_snmp_sessions_count; i++, j++)
3923
if (cancelled_agent_snmp_sessions[j] == session)
3924
i--; /* don't increase i in this loop iteration */
3926
cancelled_agent_snmp_sessions[i] = cancelled_agent_snmp_sessions[j];
3928
cancelled_agent_snmp_sessions_count = i;
3930
for (; i< cancelled_agent_snmp_sessions_max; i++)
3931
cancelled_agent_snmp_sessions[i] = NULL;