if (parseNotifRequest(ctx, messageBody, &function, ¬ifId,
- &address, &op, &conditions))
+ &address, &op, &validity, &conditions))
ret = HTTP_BADREQ;
else {
int fatal = 0, err = 0;
XMLCtx->notifChangeOp = edg_wll_StringToNotifChangeOp(pom);
free(pom);
}
+ else if (!strcmp(XMLCtx->element,"requestedValidity")) {
+ XMLCtx->notifValidity = edg_wll_from_string_to_time_t(XMLCtx);
+ }
else if (!strcmp(el,"and")) {
long len = (XML_GetCurrentByteIndex(XMLCtx->p) + XML_GetCurrentByteCount(XMLCtx->p))
- XMLCtx->jobQueryRec_begin;
return ret;
}
/* parse Notif request from client */
-int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, edg_wll_QueryRec ***conditions)
+int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, time_t *validity,edg_wll_QueryRec ***conditions)
{
int ret;
edg_wll_XML_ctx XMLCtx;
*notifId = XMLCtx.notifId;
*address = XMLCtx.notifClientAddress;
*op = XMLCtx.notifChangeOp;
+ *validity = XMLCtx.notifValidity;
*conditions = XMLCtx.job_conditions;
}
int parsePurgeRequest(edg_wll_Context ctx, char *messageBody, int (*tagToIndex)(), edg_wll_PurgeRequest *request);
int parseDumpRequest(edg_wll_Context ctx, char *messageBody, edg_wll_DumpRequest *request);
int parseLoadRequest(edg_wll_Context ctx, char *messageBody, edg_wll_LoadRequest *request);
-int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, edg_wll_QueryRec ***conditions);
+int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, time_t *validity,edg_wll_QueryRec ***conditions);
int parseQuerySequenceCodeRequest(edg_wll_Context ctx, char *messageBody, edg_wlc_JobId *jobId, char **source);
int edg_wll_QueryEventsToXML(edg_wll_Context, edg_wll_Event *, char **);
int edg_wll_QueryJobsToXML(edg_wll_Context, edg_wlc_JobId *, edg_wll_JobStat *, char **);
const char *, const char *, const char *);
+static void adjust_validity(edg_wll_Context ctx,time_t *valid)
+{
+ time_t now;
+
+ time(&now);
+
+ if (*valid <= 0) {
+ *valid = now + ctx->notifDuration;
+ }
+
+ if (ctx->peerProxyValidity && ctx->peerProxyValidity < *valid)
+ *valid = ctx->peerProxyValidity;
+
+ if (*valid - now > ctx->notifDuration)
+ *valid = now + ctx->notifDuration;
+}
+
+
int edg_wll_NotifNewServer(
edg_wll_Context ctx,
edg_wll_QueryRec const * const *conditions,
/* Format time of validity
*/
- *valid = time(NULL);
- if ( ctx->peerProxyValidity
- && (ctx->peerProxyValidity - *valid) < ctx->notifDuration )
- *valid = ctx->peerProxyValidity;
- else
- *valid += ctx->notifDuration;
+
+ if (*valid <= 0)
+ *valid = time(NULL) + ctx->notifDuration;
+ adjust_validity(ctx,valid);
+
if ( !(time_s = strdup(edg_wll_TimeToDB(*valid))) )
{
/* Format time of validity
*/
- *valid = time(NULL);
- if ( ctx->peerProxyValidity
- && (ctx->peerProxyValidity - *valid) < ctx->notifDuration )
- *valid = ctx->peerProxyValidity;
- else
- *valid += ctx->notifDuration;
+ if (*valid <= 0)
+ *valid = time(NULL) + ctx->notifDuration;
+ adjust_validity(ctx,valid);
if ( !(time_s = strdup(edg_wll_TimeToDB(*valid))) )
{
/* Format time of validity
*/
- *valid = time(NULL);
- if ( ctx->peerProxyValidity
- && (ctx->peerProxyValidity - *valid) < ctx->notifDuration )
- *valid = ctx->peerProxyValidity;
- else
- *valid += ctx->notifDuration;
+ if (*valid <= 0)
+ *valid = time(NULL) + ctx->notifDuration;
+ adjust_validity(ctx,valid);
+
if ( !(time_s = strdup(edg_wll_TimeToDB(*valid))) )
{