From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 9897A6EC56; Thu, 18 Mar 2021 23:47:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9897A6EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616100458; bh=dNUb8UuHVP1j7IsSZ7RzlxcSg9tY+1hJldYpQQsxIRw=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=qmNBuHQ4mLgKz2GTfQZk4ryIeATzwkLXPAySZM1Pym99gjdrBaVYEhqsnXOzT4Kdm 5uPtRa2xeIudAYtc5rp15JWsx5oFqwTj3p+y7ss4ayWjlgAJNkDBHKm+WE9IlYpPma 3loX+97p5N4QqGrxMm+5RfyBARinUq3QYJOdhjlY= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 02F0F6EC56 for ; Thu, 18 Mar 2021 23:47:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 02F0F6EC56 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lMzYP-0002Zu-C4; Thu, 18 Mar 2021 23:47:37 +0300 To: Cyrill Gorcunov References: Message-ID: Date: Thu, 18 Mar 2021 21:47:36 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD96485A7A9FC131893DA79D6515A0F039BBBC04D7987B60B80182A05F538085040E280738412C0AC582A47334D35A56B1BF11F1DC9C8234CE9037A79880B2F2B89 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7370F4F695FFFC24BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637826327602763C04B8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CF89CA98302ED496FF40B1E21AFBD63EE7CAFF85216F17E2FA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE7850F8B975A76562C9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3D6B8D1F75A55B56DCC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FC56969FF77163EA2B75ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4931B544F03EFBC4D570B02670E5FEECA50C4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F93F060FBA3C93C613B503F486389A921A5CC5B56E945C8DA X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2BBE337FB72E923155C0AF1600DCBC20BD52826C51A2876AB41A2AE79B6E8C909 X-C1DE0DAB: 0D63561A33F958A55386A689CF49C497AB199EF2759DBD422BEC17DE42276CE8D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75F04B387B5D7535DE410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348B409C2D257583DF0F208ABBBE2B5480EEA8A8EFDD4227DB39D1053E57FACB627C8E68E300D4C4D91D7E09C32AA3244CB29E1E6171CF1EA991E36938E70FA9A67101BF96129E4011FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyKyJYJ15DtIMx18bqM6MEQ== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382201D5B3F102E4B23135884BE69998FB763841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 1/2] swim: add SO_BROADCAST option X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the review! >> diff --git a/src/lib/swim/swim_io.c b/src/lib/swim/swim_io.c >> index c8558c43e..45df36ba4 100644 >> --- a/src/lib/swim/swim_io.c >> +++ b/src/lib/swim/swim_io.c >> @@ -512,8 +512,23 @@ static inline void >> swim_complete_send(struct swim_scheduler *scheduler, struct swim_task *task, >> ssize_t size) >> { >> - if (size < 0) >> - diag_log(); >> + if (size < 0) { >> + bool is_critical = false; >> +#if TARGET_OS_DARWIN >> + /* >> + * On Mac this error happens regularly if SWIM is bound to >> + * the localhost and tries to broadcast out of the machine. This >> + * is not critical, because will happen in the tests a lot, and >> + * in prod it simply should not bind to localhost if there are >> + * multiple machines in the cluster. Besides, Mac as a platform >> + * is not supposed to be used in prod. >> + */ >> + struct error *last = diag_last_error(diag_get()); >> + is_critical = (last->saved_errno == EADDRNOTAVAIL); >> +#endif >> + if (is_critical) >> + diag_log(); >> + } >> if (task->complete != NULL) >> task->complete(task, scheduler, size); > > Vlad, I don't understand. For non-mac users this @is_critical will > always be false, maybe we better move the whoe branch to TARGET_OS_DARWIN > then? Ie > > if (size < 0) { > #if TARGET_OS_DARWIN > if (is_critical) > diag_log(); > #endif > } > > or you made it this way to escape unused parameter compiler warning? I added the variable on all platforms on purpose. Because if the code would be done the way you propose above, non-Mac platforms won't log anything. I, on the contrary, want to log on all platforms, but not certain errors in certain platforms. Only EADDRNOTAVAIL and only on Mac. Everything else must be logged. Because the user does not call 'send' directly, and has no other way to know there was an error except via the logs. Another option would be to have it like this: #if TARGET_OS_DARWIN bool is_critical = ...; if (is_critical) diag_log(); #else diag_log(); #endif But I don't like having 2 places handling the critical error. I wanted to have only one diag_log(). Talking of the warning - I am not sure I understand. It is used on both platforms. On non-Mac it is the 'if' condition. Even if it is never changed and inlined by the compiler, it is still used. There can't be a warning.