[2623] in BarnOwl Developers
Re: [PATCH] Don't ignore the error code when doing a zwrite
daemon@ATHENA.MIT.EDU (Nelson Elhage)
Mon Sep 13 22:28:57 2010
From: Nelson Elhage <nelhage@MIT.EDU>
To: David A Benjamin <davidben@mit.edu>
Cc: barnowl-dev@mit.edu
In-Reply-To: <alpine.DEB.2.00.1009132121470.9932@superconducktor>
Date: Mon, 13 Sep 2010 22:28:53 -0400
On Mon, 13 Sep 2010 21:27:34 -0400 (EDT), David A Benjamin <davidben@MIT.EDU> wrote:
> On Mon, 13 Sep 2010, Nelson Elhage wrote:
> > Cool, definitely a good call.
>
> Yeah, there was much discussion on zephyr about this a while ago and it
> annoyed me that no one wrote a patch and did so. After which I promptly
> forgot about it for several weeks.
>
>
> > It's not hugely important, but is continuing to try further recipients
> > really the right plan if one fails? I feel like I'd expect it to bail
> > out after the first error.
>
> Mmm. I wasn't really sure what to do there. It looks like zwrite aborts. I
> retained the existing behavior, but I think I agree that aborting is
> better.
Ok, cool. Feel free to merge a patch that does that without further
review if you want to.
- Nelson
>
> David
>
> > - Nelson
> >
> > On Mon, 13 Sep 2010 18:02:37 -0700, David Benjamin <davidben@MIT.EDU> wrote:
> >> Display a com_err-supplied error message. It's about time we fix the
> >> false "Waiting for ack..." messages.
> >> ---
> >> functions.c | 7 ++++++-
> >> zwrite.c | 12 ++++++++----
> >> 2 files changed, 14 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/functions.c b/functions.c
> >> index 0da494f..8d9d01f 100644
> >> --- a/functions.c
> >> +++ b/functions.c
> >> @@ -344,6 +344,7 @@ void owl_callback_zwrite(owl_editwin *e) {
> >> void owl_function_zwrite(owl_zwrite *z, const char *msg)
> >> {
> >> owl_message *m;
> >> + int ret;
> >>
> >> if(strcmp(z->cmd, "zcrypt") == 0) {
> >> owl_function_zcrypt(z, msg);
> >> @@ -355,7 +356,11 @@ void owl_function_zwrite(owl_zwrite *z, const char *msg)
> >> if (msg) {
> >> owl_zwrite_set_message(z, msg);
> >> }
> >> - owl_zwrite_send_message(z);
> >> + ret = owl_zwrite_send_message(z);
> >> + if (ret != 0) {
> >> + owl_function_makemsg("Error sending zephyr: %s", error_message(ret));
> >> + return;
> >> + }
> >> owl_function_makemsg("Waiting for ack...");
> >>
> >> /* If it's personal */
> >> diff --git a/zwrite.c b/zwrite.c
> >> index a67864a..3d5fa45 100644
> >> --- a/zwrite.c
> >> +++ b/zwrite.c
> >> @@ -253,7 +253,7 @@ int owl_zwrite_is_message_set(const owl_zwrite *z)
> >>
> >> int owl_zwrite_send_message(const owl_zwrite *z)
> >> {
> >> - int i, j;
> >> + int i, j, ret = 0;
> >> char *to = NULL;
> >>
> >> if (z->message==NULL) return(-1);
> >> @@ -261,21 +261,25 @@ int owl_zwrite_send_message(const owl_zwrite *z)
> >> j=owl_list_get_size(&(z->recips));
> >> if (j>0) {
> >> for (i=0; i<j; i++) {
> >> + int ret2;
> >> if (strcmp(z->realm, "")) {
> >> to = owl_sprintf("%s@%s", (const char *) owl_list_get_element(&(z->recips), i), z->realm);
> >> } else {
> >> to = owl_strdup( owl_list_get_element(&(z->recips), i));
> >> }
> >> - send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message);
> >> + ret2 = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message);
> >> + /* Try to send all of them, and return the first error code. */
> >> + if (ret == 0)
> >> + ret = ret2;
> >> owl_free(to);
> >> to = NULL;
> >> }
> >> } else {
> >> to = owl_sprintf( "@%s", z->realm);
> >> - send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message);
> >> + ret = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message);
> >> }
> >> owl_free(to);
> >> - return(0);
> >> + return ret;
> >> }
> >>
> >> int owl_zwrite_create_and_send_from_line(const char *cmd, const char *msg)
> >> --
> >> 1.7.2.1.45.gb1c4
> >>
> >>
> >
>