MIME-Version: 1.0 Message-Id: <23ff8c41-2243-4561-9872-4d71dd7be0df@...2702...> In-Reply-To: <70cfc6aa-e0a4-4c89-aedd-f4f790e3679c@...2181...> References: <69296454-829c-4f6b-a528-a741e8ef96d2@...2702...> <70cfc6aa-e0a4-4c89-aedd-f4f790e3679c@...2181...> Date: Mon, 20 Nov 2023 10:40:23 +0100 From: "Savely Krasovsky" Subject: Re: [Openvpn-devel] OpenVPN3 thread safety List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: Antonio Quartulli , Arne Schwabe , openvpn-devel@lists.sourceforge.net That's exactly what I did! Works perfectly, thanks for calming me down. =D0=9F=D0=BD, 20.11.2023 =D0=B2 10:37 Antonio Quartulli =D0=BF=D0=B8=D1=81= =D0=B0=D0=BB(=D0=B0): > Hi, > > On 20/11/2023 10:11, Savely Krasovsky wrote: >> Thanks for the reply! >>=20 >> After few days I have found a major bug: a close and free client before = stop() successfully executes. After fixing this I didn't get any segfaults = anymore. Program survives very extensive tests. But after your reply I am i= n question again... Sure, openvpn3 has single thread after Connect(), but G= o still could call Stop() or any other method from another thread. And stil= l I didn't get any issues at the moment. Should I rewrite it anyway? >>=20 > > > Calling from different threads is not an issue. > Invoking multiple methods at the same time is. > > If you call openvpn3 code from multiple threads, it may be better for=20 > you to implement your own locking system "outside" of the library which=20 > makes sure no more than one caller is running openvpn3 code at a given=20 > moment. > > Cheers, > >> =D0=9F=D0=BD, 20.11.2023 =D0=B2 9:55 Arne Schwabe =D0=BF=D0=B8=D1=81=D0= =B0=D0=BB(=D0=B0): >>> Am 12.11.2023 um 14:16 schrieb Savely Krasovsky: >>>> Hello! >>>> >>>> I am trying to use OpenVPN3 with Golang SWIG binding. It works pretty = nice, but I have random segmentation faults without obvious reason. My curr= ent guess is that Golang calls OpenVPN3 from various threads and library is= not ready for that sometime. Am I right? Documentation doesn't say a lot a= bout threading. >>>> >>>> If this is a case, I have two possible solutions: >>>> 1. Use OPENVPN_ENABLE_BIGMUTEX build flag (I am not sure I need tha= t). >>>> 2. Move all calls to OpenVPN3 into single goroutine and use runtime= .LockOSThread(). >>>> >>>> Could you please clarify, should I get segfaults in that case or not a= nd the problems is unrelated. >>> >>> >>> Yes. The client is singlethreaded and expects to be called only from a >>> single thread. You can have multiple clients in multiple threads but all >>> our own software uses just a single thread for the client itself. >>> >>> >>> Arne >>=20 > > --=20 > Antonio Quartulli --=20 Best regards, Savely Krasovsky