ServerApplication oddity

General discussion regarding the development of POCO for contributors.
AjK
Posts: 4
Joined: 12 May 2012, 22:36

ServerApplication oddity

Postby AjK » 30 Aug 2014, 21:48

Hello

Looking to try to get a very minor contrib in.

Basically I recently wrote a small proof of concept program in C using libevent for the Windows platform. All went well and so I decided to switch to Poco/C++

Again, all was going well until I reached the main loop. In the C program in main() it runs something like this:-

Code: Select all

while (WaitForSingleObject(ghSvcStopEvent, 0) != WAIT_OBJECT_0) {
  event_base_loop(p_evbase, EVLOOP_ONCE | EVLOOP_NONBLOCK);
}


where ghSvcStopEvent is signalled externally by the SCM.

However, in the ServerApplication it essentially wanted me to waitForTerminationRequest();

Now here's the thing, libevent has an event loop and I have to signal it to terminate or run once non-blocking in my own while loop. But either of these mean I need to see if the termination event has fired.

And in ServerApplication the _terminated event is private and there's no "getter" for it. So I have no way to see the event.

My solution was to hack ServerApplication.h and add the protected function:-

Code: Select all

bool isTerminateSignalled() { return _terminated.tryWait(0); }


Now, it would be nice to add that into the main tree to save me re-adding it through updates.

Do I have to fork the Poco World and do a pull request for something this minor?

thanks for your time
--Andy

alex
Posts: 1375
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: ServerApplication oddity

Postby alex » 31 Aug 2014, 01:52

AjK wrote:Do I have to fork the Poco World and do a pull request for something this minor?

yes, please. also, add a test for it and pay attention to coding style guide.

guenter
Posts: 1268
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: ServerApplication oddity

Postby guenter » 31 Aug 2014, 08:57

And make sure it works on non-Windows platforms which do not use Poco::Event for signalling...

AjK
Posts: 4
Joined: 12 May 2012, 22:36

Re: ServerApplication oddity

Postby AjK » 03 Sep 2014, 01:02

Alex, Guenter

Thanks for the reply, I will follow that route. In fact I just forked it and cloned to my Linux and Windows machines (I usually start with Linux as it's just easy to get stuff done).

As normal, first step is to run a clean build with passing unit tests. While they are off doing that (takes a while) I started looking at the Util test suites to see where I could start by adding a test for the change I propose.

Hmm, there currently seems to be no tests for Application or ServerApplication, seems like I have a bit more to do to add a one line inline header function!

I'll let you know on this forum thread how I get on and ask for rfc before making a pull request.

Thanks again for your time.

Oh and I don't have access to a Mac to test the build on that platform. Hopefully I can find some friendly Mac user at PR time :)

regards,
--Andy

alex
Posts: 1375
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: ServerApplication oddity

Postby alex » 03 Sep 2014, 01:43

We'll test on Mac.

My reply about adding test was a default one as we often get contributions that should have tests but don't. That said, I would not object if you add Application tests but will not turn down the contribution without it, either. Just make sure it works on Linux and Windows. I think Mac should behave same as Linux.


Return to “Contributors”

Who is online

Users browsing this forum: No registered users and 2 guests

cron