Deleted Added
full compact
control.c (221075) control.c (221076)
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Pawel Jakub Dawidek under sponsorship from
6 * the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Pawel Jakub Dawidek under sponsorship from
6 * the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sbin/hastd/control.c 221075 2011-04-26 19:22:54Z trociny $");
31__FBSDID("$FreeBSD: head/sbin/hastd/control.c 221076 2011-04-26 19:38:30Z trociny $");
32
33#include <sys/types.h>
34#include <sys/wait.h>
35
36#include <assert.h>
37#include <errno.h>
38#include <pthread.h>
39#include <signal.h>

--- 117 unchanged lines hidden (view full) ---

157
158 cnvin = cnvout = NULL;
159 error = 0;
160
161 /*
162 * Prepare and send command to worker process.
163 */
164 cnvout = nv_alloc();
32
33#include <sys/types.h>
34#include <sys/wait.h>
35
36#include <assert.h>
37#include <errno.h>
38#include <pthread.h>
39#include <signal.h>

--- 117 unchanged lines hidden (view full) ---

157
158 cnvin = cnvout = NULL;
159 error = 0;
160
161 /*
162 * Prepare and send command to worker process.
163 */
164 cnvout = nv_alloc();
165 nv_add_uint8(cnvout, HASTCTL_STATUS, "cmd");
165 nv_add_uint8(cnvout, CONTROL_STATUS, "cmd");
166 error = nv_error(cnvout);
167 if (error != 0) {
168 pjdlog_common(LOG_ERR, 0, error,
169 "Unable to prepare control header");
170 goto end;
171 }
172 if (hast_proto_send(res, res->hr_ctrl, cnvout, NULL, 0) < 0) {
173 error = errno;

--- 248 unchanged lines hidden (view full) ---

422 cmd = nv_get_uint8(nvin, "cmd");
423 if (cmd == 0) {
424 pjdlog_error("Control message is missing 'cmd' field.");
425 nv_free(nvin);
426 continue;
427 }
428 nvout = nv_alloc();
429 switch (cmd) {
166 error = nv_error(cnvout);
167 if (error != 0) {
168 pjdlog_common(LOG_ERR, 0, error,
169 "Unable to prepare control header");
170 goto end;
171 }
172 if (hast_proto_send(res, res->hr_ctrl, cnvout, NULL, 0) < 0) {
173 error = errno;

--- 248 unchanged lines hidden (view full) ---

422 cmd = nv_get_uint8(nvin, "cmd");
423 if (cmd == 0) {
424 pjdlog_error("Control message is missing 'cmd' field.");
425 nv_free(nvin);
426 continue;
427 }
428 nvout = nv_alloc();
429 switch (cmd) {
430 case HASTCTL_STATUS:
430 case CONTROL_STATUS:
431 if (res->hr_remotein != NULL &&
432 res->hr_remoteout != NULL) {
433 nv_add_string(nvout, "complete", "status");
434 } else {
435 nv_add_string(nvout, "degraded", "status");
436 }
437 nv_add_uint32(nvout, (uint32_t)res->hr_extentsize,
438 "extentsize");

--- 4 unchanged lines hidden (view full) ---

443 (uint64_t)(activemap_ndirty(res->hr_amp) *
444 res->hr_extentsize), "dirty");
445 } else {
446 nv_add_uint32(nvout, (uint32_t)0, "keepdirty");
447 nv_add_uint64(nvout, (uint64_t)0, "dirty");
448 }
449 nv_add_int16(nvout, 0, "error");
450 break;
431 if (res->hr_remotein != NULL &&
432 res->hr_remoteout != NULL) {
433 nv_add_string(nvout, "complete", "status");
434 } else {
435 nv_add_string(nvout, "degraded", "status");
436 }
437 nv_add_uint32(nvout, (uint32_t)res->hr_extentsize,
438 "extentsize");

--- 4 unchanged lines hidden (view full) ---

443 (uint64_t)(activemap_ndirty(res->hr_amp) *
444 res->hr_extentsize), "dirty");
445 } else {
446 nv_add_uint32(nvout, (uint32_t)0, "keepdirty");
447 nv_add_uint64(nvout, (uint64_t)0, "dirty");
448 }
449 nv_add_int16(nvout, 0, "error");
450 break;
451 case HASTCTL_RELOAD:
451 case CONTROL_RELOAD:
452 /*
453 * When parent receives SIGHUP and discovers that
454 * something related to us has changes, it sends reload
455 * message to us.
456 */
457 assert(res->hr_role == HAST_ROLE_PRIMARY);
458 primary_config_reload(res, nvin);
459 nv_add_int16(nvout, 0, "error");

--- 20 unchanged lines hidden ---
452 /*
453 * When parent receives SIGHUP and discovers that
454 * something related to us has changes, it sends reload
455 * message to us.
456 */
457 assert(res->hr_role == HAST_ROLE_PRIMARY);
458 primary_config_reload(res, nvin);
459 nv_add_int16(nvout, 0, "error");

--- 20 unchanged lines hidden ---