diff src/post.c @ 223:ffb1848a39db noffle

[svn] * src/util.c: Improve (correct) error detection when updating timestamp file. * src/content.h, src/content.c: Return Boolean success/fail from Cont_write. Also ensure cont.first isn't polluted in the event of a failed update. * src/client.c,src/control.c,src/fetch.c,src/noffle.c,src/post.c, src/pseudo.c: If Cont_write fails, don't do actions that need it to have worked. Typically, don't update first and last article numbers in group database. * src/server.c: If groupinfo.lastupdate is unreadable or corrupt, spot this and report it and give an explicit error when processing NNTP NEWGROUPS command.
author bears
date Sun, 09 Dec 2001 12:31:57 +0000
parents bf290632d29e
children fbff73fe5b40
line wrap: on
line diff
--- a/src/post.c	Sun Dec 09 11:32:31 2001 +0000
+++ b/src/post.c	Sun Dec 09 12:31:57 2001 +0000
@@ -1,7 +1,7 @@
 /*
   post.c
 
-  $Id: post.c 341 2001-12-09 11:32:31Z bears $
+  $Id: post.c 342 2001-12-09 12:31:57Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -97,10 +97,14 @@
 	Db_setXref( msgId, t );
     }
     
-    Cont_write();
-    Grp_setFirstLast( Cont_grp(), Cont_first(), Cont_last() );
-    Grp_setLastPostTime( Cont_grp() );
-    return TRUE;
+    if ( Cont_write() )
+    {
+        Grp_setFirstLast( Cont_grp(), Cont_first(), Cont_last() );
+        Grp_setLastPostTime( Cont_grp() );
+        return TRUE;
+    }
+    else
+        return FALSE;
 }
 
 static Bool
@@ -179,7 +183,6 @@
     s = new_DynStr( 10000 );
     article.text = s;
 
-    memset( &article.over, 0, sizeof( article.over ) );
     replyToFound = pathFound = orgFound = FALSE;
     
     /* Grab header lines first, getting overview info as we go. */
@@ -539,6 +542,19 @@
     return postExternal() && err;
 }
 
+
+static void
+clearArticleInfo( void )
+{
+    article.text = NULL;
+    article.newsgroups = NULL;
+    article.control = NULL;
+    article.approved = FALSE;
+    article.posted = FALSE;
+    article.flags = 0;
+    memset( &article.over, 0, sizeof( article.over ) );
+}
+
 /* Register an article for posting. */
 Bool
 Post_open( const char * text, unsigned flags )
@@ -549,8 +565,9 @@
 	return FALSE;
     }
 
+    clearArticleInfo();
+    
     article.flags = flags;
-    
     if ( ! getArticleText( text ) )
 	return FALSE;
 
@@ -601,8 +618,6 @@
 	del_Itl( article.control );
 	article.control = NULL;
     }
-    article.approved = FALSE;
-    article.posted = FALSE;
 }