[2622] in BarnOwl Developers
Re: [PATCH] Don't ignore the error code when doing a zwrite
daemon@ATHENA.MIT.EDU (David A Benjamin)
Mon Sep 13 21:27:36 2010
Date: Mon, 13 Sep 2010 21:27:34 -0400 (EDT)
From: David A Benjamin <davidben@MIT.EDU>
To: Nelson Elhage <nelhage@mit.edu>
cc: barnowl-dev@mit.edu
In-Reply-To: <87hbhtqg86.fsf@mit.edu>
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.
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
>>
>>
>