Commit ce3fd630 ce3fd630f534ad8c93d912368e4512b671ae3207 by Sergey Poznyakoff

(deliver_pending_bulletins): Return immediately, if unable to count messages in the bulletin box

1 parent 397905e7
...@@ -151,7 +151,7 @@ read_bulletin_db (size_t *pnum) ...@@ -151,7 +151,7 @@ read_bulletin_db (size_t *pnum)
151 return 1; 151 return 1;
152 } 152 }
153 153
154 s = MU_DATUM_SIZE(data); 154 s = MU_DATUM_SIZE (data);
155 if (s < sizeof sbuf) 155 if (s < sizeof sbuf)
156 bufptr = sbuf; 156 bufptr = sbuf;
157 else 157 else
...@@ -165,7 +165,7 @@ read_bulletin_db (size_t *pnum) ...@@ -165,7 +165,7 @@ read_bulletin_db (size_t *pnum)
165 bufptr = buf; 165 bufptr = buf;
166 } 166 }
167 167
168 memcpy (bufptr, MU_DATUM_PTR(data), s); 168 memcpy (bufptr, MU_DATUM_PTR (data), s);
169 bufptr[s] = 0; 169 bufptr[s] = 0;
170 mu_dbm_datum_free(&data); 170 mu_dbm_datum_free(&data);
171 171
...@@ -180,7 +180,7 @@ read_bulletin_db (size_t *pnum) ...@@ -180,7 +180,7 @@ read_bulletin_db (size_t *pnum)
180 { 180 {
181 long n; 181 long n;
182 182
183 n = *(long*)MU_DATUM_PTR(data); 183 n = *(long*)MU_DATUM_PTR (data);
184 if (n >= 0) 184 if (n >= 0)
185 { 185 {
186 syslog (LOG_INFO, 186 syslog (LOG_INFO,
...@@ -220,11 +220,11 @@ write_bulletin_db (size_t num) ...@@ -220,11 +220,11 @@ write_bulletin_db (size_t num)
220 memset (&key, 0, sizeof key); 220 memset (&key, 0, sizeof key);
221 memset (&data, 0, sizeof data); 221 memset (&data, 0, sizeof data);
222 222
223 MU_DATUM_PTR(key) = username; 223 MU_DATUM_PTR (key) = username;
224 MU_DATUM_SIZE(key) = strlen (username); 224 MU_DATUM_SIZE (key) = strlen (username);
225 p = mu_umaxtostr (0, num); 225 p = mu_umaxtostr (0, num);
226 MU_DATUM_PTR(data) = p; 226 MU_DATUM_PTR (data) = p;
227 MU_DATUM_SIZE(data) = strlen (p); 227 MU_DATUM_SIZE (data) = strlen (p);
228 228
229 rc = mu_dbm_insert (db, key, data, 1); 229 rc = mu_dbm_insert (db, key, data, 1);
230 if (rc) 230 if (rc)
...@@ -274,8 +274,11 @@ deliver_pending_bulletins () ...@@ -274,8 +274,11 @@ deliver_pending_bulletins ()
274 return; 274 return;
275 lastnum = get_last_delivered_num (); 275 lastnum = get_last_delivered_num ();
276 276
277 mu_mailbox_messages_count (bull, &total); 277 rc = mu_mailbox_messages_count (bull, &total);
278 278 if (rc)
279 mu_error (_("Cannot count bulletins: %s"), mu_strerror (rc));
280 else
281 {
279 syslog (LOG_DEBUG, 282 syslog (LOG_DEBUG,
280 "user %s, last bulletin %lu, total bulletins %lu", 283 "user %s, last bulletin %lu, total bulletins %lu",
281 username, (unsigned long) lastnum, (unsigned long) total); 284 username, (unsigned long) lastnum, (unsigned long) total);
...@@ -312,6 +315,8 @@ deliver_pending_bulletins () ...@@ -312,6 +315,8 @@ deliver_pending_bulletins ()
312 } 315 }
313 store_last_delivered_num (i - 1); 316 store_last_delivered_num (i - 1);
314 } 317 }
318 }
319
315 close_bulletin_mailbox (&bull); 320 close_bulletin_mailbox (&bull);
316 } 321 }
317 322
......