Deleted Added
full compact
primary.c (212899) primary.c (213007)
1/*-
2 * Copyright (c) 2009 The FreeBSD Foundation
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

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

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

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

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sbin/hastd/primary.c 212899 2010-09-20 13:23:43Z pjd $");
32__FBSDID("$FreeBSD: head/sbin/hastd/primary.c 213007 2010-09-22 19:03:11Z pjd $");
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/refcount.h>
39#include <sys/stat.h>
40

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

802
803 signal(SIGHUP, SIG_DFL);
804 signal(SIGCHLD, SIG_DFL);
805
806 /* Declare that we are sender. */
807 proto_send(res->hr_event, NULL, 0);
808
809 init_local(res);
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/bio.h>
37#include <sys/disk.h>
38#include <sys/refcount.h>
39#include <sys/stat.h>
40

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

802
803 signal(SIGHUP, SIG_DFL);
804 signal(SIGCHLD, SIG_DFL);
805
806 /* Declare that we are sender. */
807 proto_send(res->hr_event, NULL, 0);
808
809 init_local(res);
810 if (real_remote(res) && init_remote(res, NULL, NULL))
811 sync_start();
812 init_ggate(res);
813 init_environment(res);
810 init_ggate(res);
811 init_environment(res);
812 /*
813 * Create the control thread before sending any event to the parent,
814 * as we can deadlock when parent sends control request to worker,
815 * but worker has no control thread started yet, so parent waits.
816 * In the meantime worker sends an event to the parent, but parent
817 * is unable to handle the event, because it waits for control
818 * request response.
819 */
820 error = pthread_create(&td, NULL, ctrl_thread, res);
821 assert(error == 0);
822 if (real_remote(res) && init_remote(res, NULL, NULL))
823 sync_start();
814 error = pthread_create(&td, NULL, ggate_recv_thread, res);
815 assert(error == 0);
816 error = pthread_create(&td, NULL, local_send_thread, res);
817 assert(error == 0);
818 error = pthread_create(&td, NULL, remote_send_thread, res);
819 assert(error == 0);
820 error = pthread_create(&td, NULL, remote_recv_thread, res);
821 assert(error == 0);
822 error = pthread_create(&td, NULL, ggate_send_thread, res);
823 assert(error == 0);
824 error = pthread_create(&td, NULL, sync_thread, res);
825 assert(error == 0);
824 error = pthread_create(&td, NULL, ggate_recv_thread, res);
825 assert(error == 0);
826 error = pthread_create(&td, NULL, local_send_thread, res);
827 assert(error == 0);
828 error = pthread_create(&td, NULL, remote_send_thread, res);
829 assert(error == 0);
830 error = pthread_create(&td, NULL, remote_recv_thread, res);
831 assert(error == 0);
832 error = pthread_create(&td, NULL, ggate_send_thread, res);
833 assert(error == 0);
834 error = pthread_create(&td, NULL, sync_thread, res);
835 assert(error == 0);
826 error = pthread_create(&td, NULL, ctrl_thread, res);
827 assert(error == 0);
828 (void)guard_thread(res);
829}
830
831static void
832reqlog(int loglevel, int debuglevel, struct g_gate_ctl_io *ggio, const char *fmt, ...)
833{
834 char msg[1024];
835 va_list ap;

--- 1155 unchanged lines hidden ---
836 (void)guard_thread(res);
837}
838
839static void
840reqlog(int loglevel, int debuglevel, struct g_gate_ctl_io *ggio, const char *fmt, ...)
841{
842 char msg[1024];
843 va_list ap;

--- 1155 unchanged lines hidden ---