Commit 9a5dd8d9 9a5dd8d9fefa3d4ec093c693e15e5d8f339f993f by Sergey Poznyakoff

(mbox_close): Initialize all private data

so that subsequent mailbox_open() works properly.
(mbox_is_updated): Updated comment
1 parent 499d0702
...@@ -277,7 +277,7 @@ static int ...@@ -277,7 +277,7 @@ static int
277 mbox_close (mailbox_t mailbox) 277 mbox_close (mailbox_t mailbox)
278 { 278 {
279 mbox_data_t mud = mailbox->data; 279 mbox_data_t mud = mailbox->data;
280 /* size_t i; */ 280 size_t i;
281 281
282 if (mud == NULL) 282 if (mud == NULL)
283 return EINVAL; 283 return EINVAL;
...@@ -287,10 +287,14 @@ mbox_close (mailbox_t mailbox) ...@@ -287,10 +287,14 @@ mbox_close (mailbox_t mailbox)
287 /* Make sure that we do not hold any file locking. */ 287 /* Make sure that we do not hold any file locking. */
288 locker_unlock (mailbox->locker); 288 locker_unlock (mailbox->locker);
289 289
290 #if 0 290 /* Alain: I'm not sure on the right approach especially if the client is
291 /* RFC: I'm not sure on the right approach especially if the client is
292 working in disconnected mode, where it can mailbox_close/mailbox_open 291 working in disconnected mode, where it can mailbox_close/mailbox_open
293 for each request, maybe we should keep them for a while. */ 292 for each request, maybe we should keep them for a while.
293
294 Sergey: No, it actually breaks reopening the mailbox. We should make
295 sure that the sequence mailbox_open();mailbox_close() will catch all
296 the changes that might have been done to the mailbox */
297
294 monitor_wrlock (mailbox->monitor); 298 monitor_wrlock (mailbox->monitor);
295 /* Before closing we need to remove all the messages 299 /* Before closing we need to remove all the messages
296 - to reclaim the memory 300 - to reclaim the memory
...@@ -317,7 +321,7 @@ mbox_close (mailbox_t mailbox) ...@@ -317,7 +321,7 @@ mbox_close (mailbox_t mailbox)
317 mud->uidvalidity = 0; 321 mud->uidvalidity = 0;
318 mud->uidnext = 0; 322 mud->uidnext = 0;
319 monitor_unlock (mailbox->monitor); 323 monitor_unlock (mailbox->monitor);
320 #endif 324
321 return stream_close (mailbox->stream); 325 return stream_close (mailbox->stream);
322 } 326 }
323 327
...@@ -346,11 +350,17 @@ mbox_scan (mailbox_t mailbox, size_t msgno, size_t *pcount) ...@@ -346,11 +350,17 @@ mbox_scan (mailbox_t mailbox, size_t msgno, size_t *pcount)
346 return 0; 350 return 0;
347 } 351 }
348 352
349 /* FIXME: How to handle a shrink ? meaning, the &^$^@%#@^& user start two 353 /* Alain: How to handle a shrink ? meaning, the &^$^@%#@^& user start two
350 browsers and deleted emails in one session. My views is that we should 354 browsers and deleted emails in one session. My views is that we should
351 scream bloody murder and hunt them with a machette. But for now just play 355 scream bloody murder and hunt them with a machette. But for now just play
352 dumb, but maybe the best approach is to pack our things and leave 356 dumb, but maybe the best approach is to pack our things and leave
353 .i.e exit()/abort(). */ 357 .i.e exit()/abort().
358
359 Sergey: Nope, we shouldn't abort. Handling it with MU_EVT_MAILBOX_CORRUPT
360 is sensible enough. The caller must decide what's the best approach
361 in this case. The simplest one is reopening the mailbox. Imap4d currently
362 does that. */
363
354 static int 364 static int
355 mbox_is_updated (mailbox_t mailbox) 365 mbox_is_updated (mailbox_t mailbox)
356 { 366 {
......