From 71bf72eec04cb587652f9cdbc2fdf1814e45e0ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 8 Sep 2010 12:31:09 +0000 Subject: [PATCH] Messaging support in server/client (using dest_url). --- org.glite.lb.server/src/il_notification.c | 43 ++++++++++++++++++++----------- org.glite.lb.server/src/il_notification.h | 9 +++---- org.glite.lb.server/src/notif_match.c | 19 +++----------- org.glite.lb.server/src/notification.c | 11 ++------ 4 files changed, 36 insertions(+), 46 deletions(-) diff --git a/org.glite.lb.server/src/il_notification.c b/org.glite.lb.server/src/il_notification.c index 9aaca27..5995c95 100644 --- a/org.glite.lb.server/src/il_notification.c +++ b/org.glite.lb.server/src/il_notification.c @@ -58,8 +58,7 @@ int notif_create_ulm( edg_wll_Context context, edg_wll_NotifId reg_id, - const char *host, - const uint16_t port, + const char *dest_url, const char *owner, int expires, const char *notif_data, @@ -68,6 +67,8 @@ notif_create_ulm( { int ret; edg_wll_Event *event=NULL; + char *host = NULL; + uint16_t port = 0; *ulm_data = NULL; *reg_id_s = NULL; @@ -81,8 +82,24 @@ notif_create_ulm( if (context->p_instance) event->notification.src_instance = strdup(context->p_instance); event->notification.notifId = edg_wll_NotifIdDup(reg_id); if (owner) event->notification.owner = strdup(owner); - if (host) event->notification.dest_host = strdup(host); - event->notification.dest_port = port; + if (dest_url) { + if (strstr(dest_url, "//")) { + // using complete URL + event->notification.dest_url = strdup(dest_url); + } else { + // using plain host:port + host = strrchr(dest_url, ':'); + port = atoi(host+1); + if ( !(host = strndup(dest_url, host-dest_url)) ) + { + edg_wll_SetError(context, ret = errno, "updating notification records"); + goto out; + } + event->notification.dest_host = host; + event->notification.dest_port = port; + host = NULL; + } + } if (notif_data) event->notification.jobstat = strdup(notif_data); event->notification.expires = expires; @@ -112,8 +129,7 @@ out: int edg_wll_NotifSend(edg_wll_Context context, edg_wll_NotifId reg_id, - const char *host, - int port, + const char *dest_url, const char *owner, int expires, const char *notif_data) @@ -127,8 +143,7 @@ edg_wll_NotifSend(edg_wll_Context context, if((ret=notif_create_ulm(context, reg_id, - host, - port, + dest_url, owner, expires, notif_data, @@ -169,8 +184,7 @@ out: int edg_wll_NotifJobStatus(edg_wll_Context context, edg_wll_NotifId reg_id, - const char *host, - int port, + const char *dest_url, const char *owner, int flags, int authz_flags, @@ -199,7 +213,7 @@ edg_wll_NotifJobStatus(edg_wll_Context context, goto out; } - if ((ret=edg_wll_NotifSend(context, reg_id, host, port, owner, expires, xml_esc_data))) { + if ((ret=edg_wll_NotifSend(context, reg_id, dest_url, owner, expires, xml_esc_data))) { char *ed = NULL, *et = NULL; if(ret) edg_wll_UpdateError(context, ret, "edg_wll_NotifJobStatus()"); @@ -221,11 +235,10 @@ out: int edg_wll_NotifChangeIL(edg_wll_Context context, edg_wll_NotifId reg_id, - const char *host, - int port, + const char *dest_url, int expires) { - return(edg_wll_NotifSend(context, reg_id, host, port, "", expires, "")); + return(edg_wll_NotifSend(context, reg_id, dest_url, "", expires, "")); } @@ -234,6 +247,6 @@ edg_wll_NotifCancelRegId(edg_wll_Context context, edg_wll_NotifId reg_id) { /* XXX: Jan 1 1970 00:00:01 -- quite sure to make it expire immediately */ - return(edg_wll_NotifSend(context, reg_id, NULL, 0, "", 1, "")); + return(edg_wll_NotifSend(context, reg_id, NULL, "", 1, "")); } diff --git a/org.glite.lb.server/src/il_notification.h b/org.glite.lb.server/src/il_notification.h index cf1facc..a1fcd5a 100644 --- a/org.glite.lb.server/src/il_notification.h +++ b/org.glite.lb.server/src/il_notification.h @@ -60,8 +60,7 @@ extern char *notif_ilog_file_prefix; int edg_wll_NotifSend(edg_wll_Context context, edg_wll_NotifId reg_id, - const char *host, - int port, + const char *dest_url, const char *owner, int expires, const char *notif_data); @@ -82,8 +81,7 @@ edg_wll_NotifSend(edg_wll_Context context, int edg_wll_NotifJobStatus(edg_wll_Context context, edg_wll_NotifId reg_id, - const char *host, - int port, + const char *dest_url, const char *owner, int flags, int authz_flags, @@ -101,8 +99,7 @@ edg_wll_NotifJobStatus(edg_wll_Context context, int edg_wll_NotifChangeIL(edg_wll_Context context, edg_wll_NotifId reg_id, - const char *host, - int port, + const char *dest_url, int expires); /** Cancel registration. diff --git a/org.glite.lb.server/src/notif_match.c b/org.glite.lb.server/src/notif_match.c index a8fe6fa..762e206 100644 --- a/org.glite.lb.server/src/notif_match.c +++ b/org.glite.lb.server/src/notif_match.c @@ -119,23 +119,12 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, cons else if (notif_match_conditions(ctx,oldstat,stat,jobc[4]) && notif_check_acl(ctx,stat,jobc[3], &authz_flags)) { - char *dest, *aux; - int port; + char *dest; glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "NOTIFY: %s, job %s", jobc[0], ju = edg_wlc_JobIdGetUnique(stat->jobId)); free(ju); ju = NULL; - dest = strdup(jobc[1]); - if ( !(aux = strrchr(dest, ':')) ) - { - edg_wll_SetError(ctx, EINVAL, "Can't parse notification destination"); - free(dest); - for (i=0; ip_instance = strdup(""); - if ( edg_wll_NotifJobStatus(ctx, nid, dest, port, jobc[3], atoi(jobc[5]), authz_flags, expires, *stat) ) + if ( edg_wll_NotifJobStatus(ctx, nid, dest, jobc[3], atoi(jobc[5]), authz_flags, expires, *stat) ) { - free(dest); for (i=0; i