Changeset 12757 for trunk/FACT++/dim/src/dis.c
- Timestamp:
- 01/24/12 13:41:57 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/dim/src/dis.c
r12585 r12757 133 133 int conn_id; 134 134 int exit_id; 135 char node[MAX_NODE_NAME]; 136 char task[MAX_TASK_NAME]; 135 137 } EXIT_H; 136 138 … … 1966 1968 1967 1969 DISABLE_AST 1970 *secs = 0; 1971 *millisecs = 0; 1968 1972 if(!serv_id) 1969 1973 { … … 1989 1993 *millisecs = servp->user_millisecs; 1990 1994 } 1995 /* 1991 1996 else 1992 1997 { … … 1994 1999 *millisecs = 0; 1995 2000 } 2001 */ 1996 2002 ENABLE_AST 1997 2003 return(1); … … 2345 2351 if(!(clip = find_client(conn_id))) 2346 2352 { 2353 /* 2354 dna_set_test_write(conn_id, 15); 2355 */ 2347 2356 clip = (CLIENT *)malloc(sizeof(CLIENT)); 2348 2357 clip->conn_id = conn_id; … … 2941 2950 ENABLE_AST 2942 2951 } 2943 2952 2953 static void add_exit_handler_item(int conn_id, int tag) 2954 { 2955 EXIT_H *newp; 2956 2957 DISABLE_AST 2958 if(!Exit_h_head) 2959 { 2960 Exit_h_head = (EXIT_H *)malloc(sizeof(EXIT_H)); 2961 sll_init( (SLL *) Exit_h_head ); 2962 } 2963 if( (newp = (EXIT_H *)sll_search((SLL *) Exit_h_head, 2964 (char *)&conn_id, 4)) ) 2965 { 2966 newp->conn_id = conn_id; 2967 newp->exit_id = tag; 2968 strcpy(newp->node, Net_conns[conn_id].node); 2969 strcpy(newp->task, Net_conns[conn_id].task); 2970 } 2971 else 2972 { 2973 newp = (EXIT_H *)malloc(sizeof(EXIT_H)); 2974 newp->conn_id = conn_id; 2975 newp->exit_id = tag; 2976 strcpy(newp->node, Net_conns[conn_id].node); 2977 strcpy(newp->task, Net_conns[conn_id].task); 2978 sll_insert_queue( (SLL *) Exit_h_head, (SLL *) newp ); 2979 } 2980 ENABLE_AST 2981 } 2982 2983 static void rem_exit_handler_item(EXIT_H *exitp) 2984 { 2985 2986 DISABLE_AST 2987 if(!Exit_h_head) 2988 { 2989 ENABLE_AST 2990 return; 2991 } 2992 sll_remove( (SLL *) Exit_h_head, (SLL *) exitp ); 2993 free(exitp); 2994 ENABLE_AST 2995 } 2996 2997 static EXIT_H *find_exit_handler_item(int conn_id) 2998 { 2999 EXIT_H *exitp; 3000 3001 DISABLE_AST; 3002 if(!Exit_h_head) 3003 { 3004 ENABLE_AST; 3005 return((EXIT_H *)0); 3006 } 3007 if( (exitp = (EXIT_H *) sll_search((SLL *) Exit_h_head, (char *) &conn_id, 4)) ) 3008 { 3009 ENABLE_AST; 3010 return(exitp); 3011 } 3012 ENABLE_AST; 3013 return((EXIT_H *)0); 3014 } 3015 3016 static int check_exit_handler_item(EXIT_H *exitp, int conn_id) 3017 { 3018 if( (!strcmp(exitp->node, Net_conns[conn_id].node)) && 3019 (!strcmp(exitp->task, Net_conns[conn_id].task))) 3020 { 3021 return exitp->exit_id; 3022 } 3023 return 0; 3024 } 3025 2944 3026 void add_exit_handler(int *tag, int *bufp, int *size) 2945 3027 { 2946 EXIT_H * newp;3028 EXIT_H *exitp; 2947 3029 2948 3030 if(size){} … … 2950 3032 if(*bufp) 2951 3033 { 2952 if(!Exit_h_head) 2953 { 2954 Exit_h_head = (EXIT_H *)malloc(sizeof(EXIT_H)); 2955 sll_init( (SLL *) Exit_h_head ); 2956 } 2957 newp = (EXIT_H *)malloc(sizeof(EXIT_H)); 2958 newp->conn_id = Curr_conn_id; 2959 newp->exit_id = *bufp; 2960 sll_insert_queue( (SLL *) Exit_h_head, (SLL *) newp ); 3034 add_exit_handler_item(Curr_conn_id, *bufp); 2961 3035 } 2962 3036 else 2963 3037 { 2964 if(!Exit_h_head) 2965 return; 2966 if((newp = (EXIT_H *)sll_search((SLL *) Exit_h_head, 2967 (char *)&Curr_conn_id, 4)) ) 2968 { 2969 sll_remove( (SLL *) Exit_h_head, (SLL *) newp ); 2970 } 3038 if((exitp = find_exit_handler_item(Curr_conn_id))) 3039 rem_exit_handler_item(exitp); 2971 3040 } 2972 3041 } … … 2974 3043 void dis_set_client_exit_handler(int conn_id, int tag) 2975 3044 { 2976 EXIT_H *newp; 2977 2978 DISABLE_AST 3045 EXIT_H *exitp; 3046 2979 3047 if(tag) 2980 3048 { 2981 if(!Exit_h_head) 2982 { 2983 Exit_h_head = (EXIT_H *)malloc(sizeof(EXIT_H)); 2984 sll_init( (SLL *) Exit_h_head ); 2985 } 2986 if( (newp = (EXIT_H *)sll_search((SLL *) Exit_h_head, 2987 (char *)&conn_id, 4)) ) 2988 { 2989 newp->conn_id = conn_id; 2990 newp->exit_id = tag; 3049 add_exit_handler_item(conn_id, tag); 3050 } 3051 else 3052 { 3053 if((exitp = find_exit_handler_item(conn_id))) 3054 rem_exit_handler_item(exitp); 3055 } 3056 } 3057 3058 3059 int do_exit_handler(int conn_id) 3060 { 3061 register EXIT_H *exitp; 3062 int exit_id; 3063 3064 DISABLE_AST; 3065 if((exitp = find_exit_handler_item(conn_id))) 3066 { 3067 if((exit_id = check_exit_handler_item(exitp, conn_id))) 3068 { 3069 (Client_exit_user_routine)( &exit_id ); 2991 3070 } 2992 3071 else 2993 3072 { 2994 newp = (EXIT_H *)malloc(sizeof(EXIT_H)); 2995 newp->conn_id = conn_id; 2996 newp->exit_id = tag; 2997 sll_insert_queue( (SLL *) Exit_h_head, (SLL *) newp ); 2998 } 2999 } 3000 else 3001 { 3002 if(!Exit_h_head) 3003 { 3004 ENABLE_AST 3005 return; 3006 } 3007 if( (newp = (EXIT_H *)sll_search((SLL *) Exit_h_head, 3008 (char *)&conn_id, 4)) ) 3009 { 3010 sll_remove( (SLL *) Exit_h_head, (SLL *) newp ); 3011 } 3012 } 3013 ENABLE_AST 3014 } 3015 3016 int do_exit_handler(int conn_id) 3017 { 3018 register EXIT_H *exitp; 3019 3020 DISABLE_AST; 3073 rem_exit_handler_item(exitp); 3074 } 3075 } 3076 /* 3021 3077 if(!Exit_h_head) 3022 3078 { … … 3030 3086 free(exitp); 3031 3087 } 3088 */ 3032 3089 ENABLE_AST 3033 3090 return(1);
Note:
See TracChangeset
for help on using the changeset viewer.