event.c (225787) | event.c (229945) |
---|---|
1/*- 2 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sbin/hastd/event.c 225787 2011-09-27 08:50:37Z pjd $"); | 28__FBSDID("$FreeBSD: head/sbin/hastd/event.c 229945 2012-01-10 22:39:07Z pjd $"); |
29 30#include <errno.h> 31 32#include "hast.h" 33#include "hast_proto.h" 34#include "hooks.h" 35#include "nv.h" 36#include "pjdlog.h" --- 19 unchanged lines hidden (view full) --- 56 nvout = nv_alloc(); 57 nv_add_uint8(nvout, (uint8_t)event, "event"); 58 error = nv_error(nvout); 59 if (error != 0) { 60 pjdlog_common(LOG_ERR, 0, error, 61 "Unable to prepare event header"); 62 goto done; 63 } | 29 30#include <errno.h> 31 32#include "hast.h" 33#include "hast_proto.h" 34#include "hooks.h" 35#include "nv.h" 36#include "pjdlog.h" --- 19 unchanged lines hidden (view full) --- 56 nvout = nv_alloc(); 57 nv_add_uint8(nvout, (uint8_t)event, "event"); 58 error = nv_error(nvout); 59 if (error != 0) { 60 pjdlog_common(LOG_ERR, 0, error, 61 "Unable to prepare event header"); 62 goto done; 63 } |
64 if (hast_proto_send(res, res->hr_event, nvout, NULL, 0) < 0) { | 64 if (hast_proto_send(res, res->hr_event, nvout, NULL, 0) == -1) { |
65 pjdlog_errno(LOG_ERR, "Unable to send event header"); 66 goto done; 67 } | 65 pjdlog_errno(LOG_ERR, "Unable to send event header"); 66 goto done; 67 } |
68 if (hast_proto_recv_hdr(res->hr_event, &nvin) < 0) { | 68 if (hast_proto_recv_hdr(res->hr_event, &nvin) == -1) { |
69 pjdlog_errno(LOG_ERR, "Unable to receive event header"); 70 goto done; 71 } 72 /* 73 * Do nothing with the answer. We only wait for it to be sure not 74 * to exit too quickly after sending an event and exiting immediately. 75 */ 76done: --- 10 unchanged lines hidden (view full) --- 87 const char *evstr; 88 uint8_t event; 89 int error; 90 91 PJDLOG_ASSERT(res != NULL); 92 93 nvin = nvout = NULL; 94 | 69 pjdlog_errno(LOG_ERR, "Unable to receive event header"); 70 goto done; 71 } 72 /* 73 * Do nothing with the answer. We only wait for it to be sure not 74 * to exit too quickly after sending an event and exiting immediately. 75 */ 76done: --- 10 unchanged lines hidden (view full) --- 87 const char *evstr; 88 uint8_t event; 89 int error; 90 91 PJDLOG_ASSERT(res != NULL); 92 93 nvin = nvout = NULL; 94 |
95 if (hast_proto_recv_hdr(res->hr_event, &nvin) < 0) { | 95 if (hast_proto_recv_hdr(res->hr_event, &nvin) == -1) { |
96 /* 97 * First error log as debug. This is because worker process 98 * most likely exited. 99 */ 100 pjdlog_common(LOG_DEBUG, 1, errno, 101 "Unable to receive event header"); 102 goto fail; 103 } --- 36 unchanged lines hidden (view full) --- 140 nvout = nv_alloc(); 141 nv_add_int16(nvout, 0, "error"); 142 error = nv_error(nvout); 143 if (error != 0) { 144 pjdlog_common(LOG_ERR, 0, error, 145 "Unable to prepare event header"); 146 goto fail; 147 } | 96 /* 97 * First error log as debug. This is because worker process 98 * most likely exited. 99 */ 100 pjdlog_common(LOG_DEBUG, 1, errno, 101 "Unable to receive event header"); 102 goto fail; 103 } --- 36 unchanged lines hidden (view full) --- 140 nvout = nv_alloc(); 141 nv_add_int16(nvout, 0, "error"); 142 error = nv_error(nvout); 143 if (error != 0) { 144 pjdlog_common(LOG_ERR, 0, error, 145 "Unable to prepare event header"); 146 goto fail; 147 } |
148 if (hast_proto_send(res, res->hr_event, nvout, NULL, 0) < 0) { | 148 if (hast_proto_send(res, res->hr_event, nvout, NULL, 0) == -1) { |
149 pjdlog_errno(LOG_ERR, "Unable to send event header"); 150 goto fail; 151 } 152 nv_free(nvin); 153 nv_free(nvout); 154 return (0); 155fail: 156 if (nvin != NULL) 157 nv_free(nvin); 158 if (nvout != NULL) 159 nv_free(nvout); 160 return (-1); 161} | 149 pjdlog_errno(LOG_ERR, "Unable to send event header"); 150 goto fail; 151 } 152 nv_free(nvin); 153 nv_free(nvout); 154 return (0); 155fail: 156 if (nvin != NULL) 157 nv_free(nvin); 158 if (nvout != NULL) 159 nv_free(nvout); 160 return (-1); 161} |