9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] manual suggestions and upas/fs bug
@ 2002-09-17 13:28 Russ Cox
  0 siblings, 0 replies; 12+ messages in thread
From: Russ Cox @ 2002-09-17 13:28 UTC (permalink / raw)
  To: 9fans

> p = realloc(p,n) is almost always a mistake.  If the allocation
> fails, the previous pointer value in p gets replaced by a null
> pointer value, so you lose the handle to the data that did not
> get extended (or, rarely, shrunk).

maybe this is what lucio was getting at, but when the next line is

	if(p == 0)
		sysfatal("out of memory");

then it doesn't really matter that we've lost the old p.



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: [9fans] manual suggestions and upas/fs bug
@ 2002-09-17 23:05 Russ Cox
  2002-09-18  2:06 ` Lyndon Nerenberg
  0 siblings, 1 reply; 12+ messages in thread
From: Russ Cox @ 2002-09-17 23:05 UTC (permalink / raw)
  To: 9fans

> We have both client and server bugs here.

Thanks for your pointers.  The IMAP client code has been
cobbled together by a few people (myself included) who knew
nothing about IMAP before working on it, so it's not surprising
that these inefficiencies exist.

> And *again* the server said there were no messages, thus
>
>    -> 9X4 UID FETCH 1:* UID
>
> is completely bogus. That message range is invalid, and the client
> should know that. However, the server should be responding with
> something like
>
>    9X4 BAD Invalid sequence in FETCH

I don't see why it's invalid and not just empty,
but I agree that it is inefficient for the client to
be sending it.

Russ



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: [9fans] manual suggestions and upas/fs bug
@ 2002-09-17  4:58 Russ Cox
  0 siblings, 0 replies; 12+ messages in thread
From: Russ Cox @ 2002-09-17  4:58 UTC (permalink / raw)
  To: 9fans

Thanks for your suggestions.  I've updated the
man pages and made the fixes to upas/fs.

I take back what I said yesterday or the day
before about IMAP being much slower than POP.
It appears that I fixed that (the overhead I was
remembering was due to constantly redialing rather
than staying dialed in, but now the code
stays dialed in).

Russ


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: [9fans] manual suggestions and upas/fs bug
@ 2002-09-17  4:34 David Swasey
  2002-09-17 20:18 ` Lyndon Nerenberg
  0 siblings, 1 reply; 12+ messages in thread
From: David Swasey @ 2002-09-17  4:34 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 788 bytes --]

I did not spend much time on this and am not an authority on IMAP or
upas/fs.  I could be wrong.

>Can you send me an
>IMAP protocol trace? (Along with the banner from the server.)

The trace is attached.  "8.out" is upas/fs with modified erealloc,
with the original imap4read, and with line 794 of imap.c changed to
read

	imap->debug = 1;

I modified the trace to hide my password.  Let me know if you had
something else in mind.

>What does "not like" mean in this context?

It appears the server closed the connection.  Since there is no "<-"
in the trace following the UID FETCH command, I think the first
Brdline call in imap4resp returned zero.

If it helps, I can temporarily deliver my mail elsewhere and give you
my password to this IMAP server.

-dave

[-- Attachment #2: Type: text/plain, Size: 614 bytes --]

term% ./8.out -f /imap/postoffice.srv.cs.cmu.edu
<- * OK postoffice.srv.cs.cmu.edu Cyrus IMAP4 v1.5.2 server ready
-> 9X1 LOGIN swasey ***************
<- 9X1 OK User logged in
-> 9X2 SELECT Inbox
<- * FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
<- * OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen \*)]
<- * 0 EXISTS
<- * 0 RECENT
<- * OK [UIDVALIDITY 1031763467]
<- 9X2 OK [READ-WRITE] Completed
-> 9X3 STATUS Inbox (MESSAGES UIDVALIDITY)
<- * STATUS Inbox (MESSAGES 0 UIDVALIDITY 1031763467)
<- 9X3 OK Completed
-> 9X4 UID FETCH 1:* UID
./8.out: opening mailbox: i/o error
term%

^ permalink raw reply	[flat|nested] 12+ messages in thread
* [9fans] manual suggestions and upas/fs bug
@ 2002-09-16 19:29 David Swasey
  2002-09-17  1:58 ` Lyndon Nerenberg
  2002-09-17  8:47 ` Douglas A. Gwyn
  0 siblings, 2 replies; 12+ messages in thread
From: David Swasey @ 2002-09-16 19:29 UTC (permalink / raw)
  To: 9fans

Hi,

The malloc(2) page says:

	The call realloc(0, size) means the same as `malloc(size)'.
	Further, the call realloc(ptr, 0) means the same as
	`free(ptr)'.

I suggest you clarify the meaning of realloc(0,0).

The manual pages filter(1), mail(1), marshal(1), mlmgr(1), nedmail(1),
upasfs(4), pop3(8), send(8), and smtp(8) refer to aliasmail(1) which
does not exist.  The file /sys/man/8/INDEX.html refers to aliasmail(8)
which exists.  I suggest you decide if its aliasmail(8) or
aliasmail(1) and make the appropriate changes.

Upas/fs dies when working with an empty IMAP4 mail box.  There are two
problems, both in /sys/src/cmd/upas/fs/imap4.c:/^imap4read.  First,
when imap->nmsg is 0, the erealloc() call will fail.  Second, the
IMAP4 server I talk to (cyrus) does not like the command "UID FETCH
1:* UID" when there are no messages.  My fix was to change the
semantics of erealloc(_,0) and to avoid the offending IMAP command.
Diffs follow.

-dave

diff /n/dump/2002/0916/sys/src/cmd/upas/fs/imap4.c imap4.c
557,559c557,561
< 	imap4cmd(imap, "UID FETCH 1:* UID");
< 	if(!isokay(s = imap4resp(imap)))
< 		return s;
---
> 	if(imap->nmsg > 0){
> 		imap4cmd(imap, "UID FETCH 1:* UID");
> 		if(!isokay(s = imap4resp(imap)))
> 			return s;
> 	}
diff /n/dump/2002/0916/sys/src/cmd/upas/fs/mbox.c mbox.c
1358c1358,1362
< 	p = realloc(p, n);
---
> 	if(n==0){
> 		free(p);
> 		p = malloc(n);
> 	} else
> 		p = realloc(p, n);



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2002-09-18 17:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-17 13:28 [9fans] manual suggestions and upas/fs bug Russ Cox
  -- strict thread matches above, loose matches on Subject: below --
2002-09-17 23:05 Russ Cox
2002-09-18  2:06 ` Lyndon Nerenberg
2002-09-18 17:03   ` rob pike, esq.
2002-09-17  4:58 Russ Cox
2002-09-17  4:34 David Swasey
2002-09-17 20:18 ` Lyndon Nerenberg
2002-09-16 19:29 David Swasey
2002-09-17  1:58 ` Lyndon Nerenberg
2002-09-17  8:47 ` Douglas A. Gwyn
2002-09-17  9:17   ` Lucio De Re
2002-09-18  8:37     ` Douglas A. Gwyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).