Browse code

script callbacks: onsend_route correction

- The pre-script callbacks are executed only
if the onsend_route is defined.
- The callbacks can access the socket info.

Miklos Tirpak authored on 01/06/2009 14:33:59
Showing 1 changed files
... ...
@@ -63,22 +63,22 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
63 63
 	int ret;
64 64
 	struct run_act_ctx ra_ctx;
65 65
 
66
-	if (exec_pre_script_cb(orig_msg, ONSEND_CB_TYPE)>0) {
67
-		ret=1;
68
-		if (onsend_rt.rlist[DEFAULT_RT]){
69
-			onsnd_info.to=&dst->to;
70
-			onsnd_info.send_sock=dst->send_sock;
71
-			onsnd_info.buf=buf;
72
-			onsnd_info.len=len;
73
-			p_onsend=&onsnd_info;
74
-			set_route_type(ONSEND_ROUTE);
66
+	ret=1;
67
+	if (onsend_rt.rlist[DEFAULT_RT]){
68
+		onsnd_info.to=&dst->to;
69
+		onsnd_info.send_sock=dst->send_sock;
70
+		onsnd_info.buf=buf;
71
+		onsnd_info.len=len;
72
+		p_onsend=&onsnd_info;
73
+		set_route_type(ONSEND_ROUTE);
74
+		if (exec_pre_script_cb(orig_msg, ONSEND_CB_TYPE)>0) {
75 75
 			init_run_actions_ctx(&ra_ctx);
76 76
 			ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
77
-			p_onsend=0; /* reset it */
77
+			exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
78
+		} else {
79
+			ret=0; /* drop the message */
78 80
 		}
79
-		exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
80
-	} else {
81
-		ret = 0;
81
+		p_onsend=0; /* reset it */
82 82
 	}
83 83
 	return ret;
84 84
 }