Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
28.08.2017 12:49, Slavomir Skopalik wrote: And by the way, Embarcadero in delphi IBX code don't counted with that. FIBC and all derivates has the worst event component that I've ever seen. It can work only in simplest cases and only by stupid luck. -- WBR, SD. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
But this mean to have some global dispatcher that will die as last object during termination process. This is far from clean programing. And by the way, Embarcadero in delphi IBX code don't counted with that. Slavek 28.08.2017 11:09, Paul Reeves wrote: The event listener should really be running in its own thread. Actually, callback is already called in its own thread. If a programmer is aware of that and coded it properly - there is no problem with extra calls. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
28.08.2017 12:40, Slavomir Skopalik wrote: there are two different situation: 1. cancel is call from different thread 2. cancel is called from call back You don't need (and actually, cannot) cancel events from callback. Why this: If you are create a object that wraps this interface, destruction of this object must be graceful. If call back happens when object is already destroyed, it causes random behavior and very hard to find. That's why you must not create such objects. Callbacks were designed for procedural programming. Callback function in any case must be a plain global routine. If you sill insist on using objects, create subscribed objects list and remove the object from it on destruction. Don't rely on dirty hack with typecast of callback's parameter. -- WBR, SD. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
Thread is created inside gds32.dll. Slavek Maybe I'm missing something, but I seem to recall from the code that you posted that your listener is running on a timer in the main thread. The event listener should really be running in its own thread. Have you tried that? Paul -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
28.08.2017 11:09, Paul Reeves wrote: The event listener should really be running in its own thread. Actually, callback is already called in its own thread. If a programmer is aware of that and coded it properly - there is no problem with extra calls. -- WBR, SD. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
On Mon, 28 Aug 2017 11:01:16 +0200 Slavomir Skopalik wrote > > > > On 28.08.2017 04:15, Slavomir Skopalik wrote: > >> Should I create ticket for this? > >> > > > > No. Removing that call will break old code. > > You mean, old code will not crash so often. > How much time I have to wait to be sure that no more call back? > Or is there other technique how to solve it? > > > > >> From programing theory, no call back after successful cancel event > >> is allowed. > > > > To be precise - it happens during event cancellation. > > This is not true, call back happen in normal case few ms after > cancellation returns. > But on heavily loaded system, it can be few seconds. Maybe I'm missing something, but I seem to recall from the code that you posted that your listener is running on a timer in the main thread. The event listener should really be running in its own thread. Have you tried that? Paul -- Paul Reeves http://www.ibphoenix.com Supporting users of Firebird -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
28.08.2017 3:15, Slavomir Skopalik wrote: From programing theory, no call back after successful cancel event is allowed. From your theory, how should be thread waiting with isc_event_wait() to be aborted without calling callback on cancel? -- WBR, SD. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
28.08.2017 11:01, Slavomir Skopalik wrote: How much time I have to wait to be sure that no more call back? Or is there other technique how to solve it? Yes: ritht callback routine can only set flags. In any case it can call (almost) nothing from ISC API and have to return ASAP. -- WBR, SD. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
On 28.08.2017 04:15, Slavomir Skopalik wrote: Should I create ticket for this? No. Removing that call will break old code. You mean, old code will not crash so often. How much time I have to wait to be sure that no more call back? Or is there other technique how to solve it? From programing theory, no call back after successful cancel event is allowed. To be precise - it happens during event cancellation. This is not true, call back happen in normal case few ms after cancellation returns. But on heavily loaded system, it can be few seconds. Slavek -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
On 28.08.2017 04:15, Slavomir Skopalik wrote: Should I create ticket for this? No. Removing that call will break old code. From programing theory, no call back after successful cancel event is allowed. To be precise - it happens during event cancellation. Slavek Hi all, I'm testing Firebird-3.0.3.32798-0_Win32 client and I found strange behavior when I canceling event by isc_cancel_events. I supposed that after that call, no call back happen, but in reality it is happen. Is it correct? One callback always happens after canceling events - it was API behavior since IB times. It's supposed you are closing your events' listener on that callback. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
Should I create ticket for this? From programing theory, no call back after successful cancel event is allowed. Slavek Hi all, I'm testing Firebird-3.0.3.32798-0_Win32 client and I found strange behavior when I canceling event by isc_cancel_events. I supposed that after that call, no call back happen, but in reality it is happen. Is it correct? One callback always happens after canceling events - it was API behavior since IB times. It's supposed you are closing your events' listener on that callback. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
Not exactly, procedure EventCallback(P: Pointer; Length: Short; Updated: PByte); cdecl; var e:TFBEvents; begin if (Assigned(P) and Assigned(Updated)) then begin e:=TFBEvents(p); try e.FSO.Enter; e.EventsReceived := true; if e.ResultBuffer<>nil then Move(Updated[0], e.ResultBuffer[0], Length); finally e.FSO.Leave; end; end; end; And event is firing on timer: procedure TFBEvents.OnTimerTimer(Sender: TObject); var i: Integer; bt : TBytes; FCancelAlerts : Boolean; begin FSO.Enter; try FDatabase.GDSLibrary.isc_event_counts(@FStatus, EventBufferLen, EventBuffer, ResultBuffer); if Assigned(FOnEventAlert) and (not FirstTime) then begin FCancelAlerts := false; for i := 0 to FEvents.Count - 1 do begin if (FStatus[i] <> 0) then begin bt := FEvents[i]; FOnEventAlert(self, TEncoding.ANSI.GetString(bt, 0, Length(bt) - 1), FStatus[i], FCancelAlerts) end; end; end; FirstTime := false; finally FSO.Leave; end; SQueEvents; end; Timer is in this example sets to 20ms. And one of Event causes event unregistration. Slavek One callback always happens after canceling events - it was API behavior since IB times. It's supposed you are closing your events' listener on that callback. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
On 25.08.2017 13:36, Slavomir Skopalik wrote: Hi all, I'm testing Firebird-3.0.3.32798-0_Win32 client and I found strange behavior when I canceling event by isc_cancel_events. I supposed that after that call, no call back happen, but in reality it is happen. Is it correct? One callback always happens after canceling events - it was API behavior since IB times. It's supposed you are closing your events' listener on that callback. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
But I'm talking about fbclient.dll. It is problematic, because in that concept mean, one times when you give a call back address. fbclient can call any time during application run independently to isc_cancel_event. I did see any problem with second channel. In normal model when I canceling some async operation, I in critical section invalidate call backs, wait for thread finish and that's all. From my point of view, I use fbclient wrong way or there is bug in fbclient. Slavek Ing. Slavomir Skopalik Executive Head Elekt Labs s.r.o. Collection and evaluation of data from machines and laboratories by means of system MASA (http://www.elektlabs.cz/m2demo) - Address: Elekt Labs s.r.o. Chaloupky 158 783 72 Velky Tynec Czech Republic --- Mobile: +420 724 207 851 icq:199 118 333 skype:skopaliks e-mail:skopa...@elektlabs.cz http://www.elektlabs.cz On 25.8.2017 12:42, Jiří Činčura wrote: I supposed that after that call, no call back happen, but in reality it is happen. Is it correct? I'd say it is (I have the same in FirebirdClient during tests under load) and even understandable. Given by design it's 2nd "channel" and the processing between regular connection and aux connection is not synchronous. Well, at least on such assumption I've built it in FirebirdClient. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] fbclient - Event call back is called after isc_cancel_events
> I supposed that after that call, no call back happen, but in reality it > is happen. > > Is it correct? I'd say it is (I have the same in FirebirdClient during tests under load) and even understandable. Given by design it's 2nd "channel" and the processing between regular connection and aux connection is not synchronous. Well, at least on such assumption I've built it in FirebirdClient. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel