Refresh feed expiration time after historic feed.
authorJiří Filipovič <fila@ics.muni.cz>
Fri, 2 May 2008 12:20:54 +0000 (12:20 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Fri, 2 May 2008 12:20:54 +0000 (12:20 +0000)
org.glite.jp.primary/src/feed.c
org.glite.jp.primary/src/new_ftp_backend.c

index 76a22e8..c5e9e23 100644 (file)
@@ -755,8 +755,13 @@ static int register_feed_deferred(glite_jp_context_t ctx,void *feed)
        struct jpfeed   *f = feed;
 
        if (glite_jppsbe_store_feed(ctx,f)) fputs(glite_jp_error_chain(ctx),stderr);
-       else kill(-master,SIGUSR1);     /* gracefully terminate slaves 
+       else{
+               time(&(f->expires));
+               f->expires += FEED_TTL;
+               glite_jppsbe_refresh_feed(ctx, f->id, f->expires);
+               kill(-master,SIGUSR1);  /* gracefully terminate slaves 
                                   and let master restart them */
+       }
 
        return 0;
 }
@@ -785,6 +790,8 @@ int glite_jpps_refresh_feed(glite_jp_context_t ctx, char *feed_id,  time_t *expi
        time(expires); *expires += FEED_TTL;
 
        glite_jppsbe_refresh_feed(ctx, feed_id, expires);
+
+       printf("Feed %s has been refreshed.\n", feed_id);
        
        return 0;       
 }
index 40da0c9..902b43d 100644 (file)
@@ -1834,16 +1834,17 @@ cleanup:
 int glite_jppsbe_refresh_feed(
         glite_jp_context_t ctx,
         char *feed_id,
-       time_t *expires
+       time_t expires
 )
 {
        glite_jp_error_t        err;
         memset(&err,0,sizeof err);
 
        char *stmt = NULL;
-
-       trio_asprintf(&stmt, "update feeds set expires=%s where feedid='%ISs'",
-               expires, feed_id);
+       char *e = NULL;
+       glite_lbu_TimeToDB(expires, &e);
+       trio_asprintf(&stmt, "update feeds set expires=%s where feedid=%s",
+               e, feed_id);
        if (!stmt) {
                 err.code = ENOMEM;
                 goto error_out;