Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYHYm-0007p6-Nv for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Oct 2021 00:46:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mYHYk-0005rG-PI for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Oct 2021 00:46:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYHYk-0005r8-HE for pgsql-hackers@lists.postgresql.org; Thu, 07 Oct 2021 00:46:54 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYHYi-0002uy-52 for pgsql-hackers@postgresql.org; Thu, 07 Oct 2021 00:46:53 +0000 Received: from hrk.local (p2388012-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.12]) by oss.nttdata.com (Postfix) with ESMTPSA id 1239A6060A; Thu, 7 Oct 2021 09:46:48 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.3 at oss.nttdata.com Subject: Re: [EXTERNAL] Re: PQcancel does not use tcp_user_timeout, connect_timeout and keepalive settings To: Jelte Fennema , Zhihong Yu Cc: "pgsql-hackers@postgresql.org" References: From: Fujii Masao Message-ID: Date: Thu, 7 Oct 2021 09:46:47 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/10/07 4:58, Jelte Fennema wrote: > Ugh forgot to attach the patch. Here it is. Thanks for working on this patch! @@ -4546,10 +4684,21 @@ PQrequestCancel(PGconn *conn) return false; } - - r = internal_cancel(&conn->raddr, conn->be_pid, conn->be_key, Since PQrequestCancel() is marked as deprecated, I don't think that we need to add the feature into it. + if (cancel->pgtcp_user_timeout >= 0) { + if (setsockopt(tmpsock, IPPROTO_TCP, TCP_USER_TIMEOUT, + (char *) &cancel->pgtcp_user_timeout, + sizeof(cancel->pgtcp_user_timeout)) < 0) { + goto cancel_errReturn; + } + } libpq has already setKeepalivesXXX() functions to do the almost same thing. Isn't it better to modify and reuse them instead of adding the almost same code, to simplify the code? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION