control.c (217737) | control.c (217784) |
---|---|
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 217737 2011-01-22 23:30:01Z pjd $"); | 31__FBSDID("$FreeBSD: head/sbin/hastd/control.c 217784 2011-01-24 15:04:15Z pjd $"); |
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> --- 366 unchanged lines hidden (view full) --- 406 pthread_exit(NULL); 407 } 408 cmd = nv_get_uint8(nvin, "cmd"); 409 if (cmd == 0) { 410 pjdlog_error("Control message is missing 'cmd' field."); 411 nv_free(nvin); 412 continue; 413 } | 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> --- 366 unchanged lines hidden (view full) --- 406 pthread_exit(NULL); 407 } 408 cmd = nv_get_uint8(nvin, "cmd"); 409 if (cmd == 0) { 410 pjdlog_error("Control message is missing 'cmd' field."); 411 nv_free(nvin); 412 continue; 413 } |
414 nv_free(nvin); | |
415 nvout = nv_alloc(); 416 switch (cmd) { 417 case HASTCTL_STATUS: 418 if (res->hr_remotein != NULL && 419 res->hr_remoteout != NULL) { 420 nv_add_string(nvout, "complete", "status"); 421 } else { 422 nv_add_string(nvout, "degraded", "status"); --- 5 unchanged lines hidden (view full) --- 428 (uint32_t)res->hr_keepdirty, "keepdirty"); 429 nv_add_uint64(nvout, 430 (uint64_t)(activemap_ndirty(res->hr_amp) * 431 res->hr_extentsize), "dirty"); 432 } else { 433 nv_add_uint32(nvout, (uint32_t)0, "keepdirty"); 434 nv_add_uint64(nvout, (uint64_t)0, "dirty"); 435 } | 414 nvout = nv_alloc(); 415 switch (cmd) { 416 case HASTCTL_STATUS: 417 if (res->hr_remotein != NULL && 418 res->hr_remoteout != NULL) { 419 nv_add_string(nvout, "complete", "status"); 420 } else { 421 nv_add_string(nvout, "degraded", "status"); --- 5 unchanged lines hidden (view full) --- 427 (uint32_t)res->hr_keepdirty, "keepdirty"); 428 nv_add_uint64(nvout, 429 (uint64_t)(activemap_ndirty(res->hr_amp) * 430 res->hr_extentsize), "dirty"); 431 } else { 432 nv_add_uint32(nvout, (uint32_t)0, "keepdirty"); 433 nv_add_uint64(nvout, (uint64_t)0, "dirty"); 434 } |
435 nv_add_int16(nvout, 0, "error"); |
|
436 break; | 436 break; |
437 case HASTCTL_RELOAD: 438 /* 439 * When parent receives SIGHUP and discovers that 440 * something related to us has changes, it sends reload 441 * message to us. 442 */ 443 assert(res->hr_role == HAST_ROLE_PRIMARY); 444 primary_config_reload(res, nvin); 445 nv_add_int16(nvout, 0, "error"); 446 break; |
|
437 default: 438 nv_add_int16(nvout, EINVAL, "error"); 439 break; 440 } | 447 default: 448 nv_add_int16(nvout, EINVAL, "error"); 449 break; 450 } |
451 nv_free(nvin); |
|
441 if (nv_error(nvout) != 0) { 442 pjdlog_error("Unable to create answer on control message."); 443 nv_free(nvout); 444 continue; 445 } 446 if (hast_proto_send(NULL, res->hr_ctrl, nvout, NULL, 0) < 0) { 447 pjdlog_errno(LOG_ERR, 448 "Unable to send reply to control message"); 449 } 450 nv_free(nvout); 451 } 452 /* NOTREACHED */ 453 return (NULL); 454} | 452 if (nv_error(nvout) != 0) { 453 pjdlog_error("Unable to create answer on control message."); 454 nv_free(nvout); 455 continue; 456 } 457 if (hast_proto_send(NULL, res->hr_ctrl, nvout, NULL, 0) < 0) { 458 pjdlog_errno(LOG_ERR, 459 "Unable to send reply to control message"); 460 } 461 nv_free(nvout); 462 } 463 /* NOTREACHED */ 464 return (NULL); 465} |