static time_t purge_timeout[EDG_WLL_NUMBER_OF_STATCODES];
-static time_t notif_duration = 60*60*24*7;
+static time_t notif_duration_max = 60*60*24,
+ notif_duration = 60*60*2;
static edg_wll_GssCred mycred = NULL;
time_t cert_mtime = 0;
"\t-l, --semaphores number of semaphores (job locks) to use\n"
"\t-i, --pidfile\t file to store master pid\n"
"\t-L, --limits\t query limits numbers in format \"events_limit:jobs_limit:size_limit\"\n"
- "\t-N, --notif-dur\t Maximal duration of notification registrations in hours\n"
+ "\t-N, --notif-dur default[:max]\t Duration of notification registrations in seconds (default and maximal)\n"
"\t-S, --purge-prefix\t purge files full-path prefix\n"
"\t-D, --dump-prefix\t dump files full-path prefix\n"
"\t-J, --jpreg-dir\t JP registration temporary files prefix (implies '-j')\n"
return 1;
}
break;
- case 'N': notif_duration = atoi(optarg) * (60*60); break;
+ case 'N': {
+ int std,max;
+ switch (sscanf(optarg,"%d:%d",&std,&max)) {
+ case 2: notif_duration_max = max;
+ /* fallthrough */
+ case 1: notif_duration = std;
+ break;
+ default:
+ usage(name);
+ return 1;
+ }
+ } break;
case 'X': notif_ilog_socket_path = strdup(optarg); break;
case 'Y': notif_ilog_file_prefix = strdup(optarg); break;
case 'i': strcpy(pidfile,optarg); break;
/* set globals
*/
ctx->notifDuration = notif_duration;
+ ctx->notifDurationMax = notif_duration_max;
ctx->purgeStorage = strdup(purgeStorage);
ctx->dumpStorage = strdup(dumpStorage);
if ( jpreg ) ctx->jpreg_dir = strdup(jpregDir); else ctx->jpreg_dir = NULL;
/* set globals
*/
ctx->notifDuration = notif_duration;
+ ctx->notifDurationMax = notif_duration_max;
if ( jpreg ) ctx->jpreg_dir = strdup(jpregDir); else ctx->jpreg_dir = NULL;
ctx->allowAnonymous = 1;
ctx->isProxy = 1;
const char *, const char *, const char *);
static int get_indexed_cols(edg_wll_Context,char const *,edg_wll_QueryRec **,char **);
+static void adjust_validity(edg_wll_Context,time_t *);
int edg_wll_NotifNewServer(
/* Format time of validity
*/
- *valid = time(NULL);
- if ( ctx->peerProxyValidity
- && (ctx->peerProxyValidity - *valid) < ctx->notifDuration )
- *valid = ctx->peerProxyValidity;
- else
- *valid += ctx->notifDuration;
+
+/* XXX: until valid works [inout] */
+ *valid = time(NULL) + ctx->notifDuration;
+ adjust_validity(ctx,valid);
glite_lbu_TimeToDB(*valid, &time_s);
if ( !time_s )
/* Format time of validity
*/
- *valid = time(NULL);
- if ( ctx->peerProxyValidity
- && (ctx->peerProxyValidity - *valid) < ctx->notifDuration )
- *valid = ctx->peerProxyValidity;
- else
- *valid += ctx->notifDuration;
+
+/* XXX: until valid works [inout] */
+ *valid = time(NULL) + ctx->notifDuration;
+ adjust_validity(ctx,valid);
glite_lbu_TimeToDB(*valid, &time_s);
if ( !time_s )
/* Format time of validity
*/
- *valid = time(NULL);
- if ( ctx->peerProxyValidity
- && (ctx->peerProxyValidity - *valid) < ctx->notifDuration )
- *valid = ctx->peerProxyValidity;
- else
- *valid += ctx->notifDuration;
+
+/* XXX: until valid works [inout] */
+ *valid = time(NULL) + ctx->notifDuration;
+ adjust_validity(ctx,valid);
glite_lbu_TimeToDB(*valid, &time_s);
if ( !time_s )
*update_out = aux;
return edg_wll_ResetError(ctx);
}
+
+static void adjust_validity(edg_wll_Context ctx,time_t *valid)
+{
+ time_t now;
+
+ if (*valid <= 0) {
+ time(&now);
+ *valid = now + ctx->notifDuration;
+ }
+
+ if (ctx->peerProxyValidity && ctx->peerProxyValidity < *valid)
+ *valid = ctx->peerProxyValidity;
+
+ if (*valid - now > ctx->notifDurationMax)
+ *valid = now + ctx->notifDurationMax;
+}
+