Archive

Archive for March, 2016

Apache webserver error on startup

March 29th, 2016 Comments off

I don’t use Apache that often, (not as often as I used to), but when I do I sometime get an error telling me that

(OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:443 no listening sockets available, shutting down Unable to open logs

Now in my case the error was because of skype.exe that was using port 443

But if you need to know who is using it simply open the command line and type

netstat -ano

And, somewhere in the list, you will give see something that is using 0.0.0.0:443, but you will not see the name, you will see the pid, (the process id).

BTW: to get the error message, you can get it via the logs or you can open a command line and run the Apache server manually.

httpd.exe -k start

Categories: Apache Tags: , ,

What I had forgotten about WM_CLOSE

March 28th, 2016 Comments off

When I was working on the next version of Piger I would sometime get an issue when using the this.bye command, (to close Piger).

What happens in the background is I call WM_CLOSE to close the active window, this message is sent to all the windows.

When it is processed by the message pump no other messages are been processed, this is a problem in case some windows are still dishing out messages, (like a fading dialog box in our example).

So remember, once you call WM_CLOSE, all bets are off and your message pump is as good as dead.

Best to have your own ‘Close()’ that does all the housekeeping in the background before you actually post WM_CLOSE to the main thread…

Otherwise your app my appear to hang.

Preventing embedded python from killing your app

March 2nd, 2016 Comments off

I was looking at a defect in Piger where a Python script could close Piger itself, it wasn’t a crash, but rather a graceful exit.

import am
am.say( "Bye", 1, 1 );
exit(1);

The problem was with the way I was calling the script rather than anything wrong with Piger or Python itself.

Somewhere in the Python virtual machine I had something like…

...
if( -1 == PyRun_SimpleString( ... ) )
{
...
}
...

And, while that works fine in most cases, if I have an exit( xyz ) in my script, piger would close.
So the answer was to replace it with …


...
PyObject * PyRes = PyRun_String(s, Py_file_input, main_dict, main_dict);
PyObject* ex = PyErr_Occurred();
if( NULL != ex)
{
...
}
...

The one last problem was, how to tell if the error was because of an exit(…) or because of an error.


...
PyObject * PyRes = PyRun_String(s, Py_file_input, main_dict, main_dict);
PyObject* ex = PyErr_Occurred();
if( NULL != ex)
{
// if we exit(...) then 'ex' is not NULL, so we must check for that.
if (!PyErr_ExceptionMatches(PyExc_SystemExit))
{
// this is a real coding error.
}
}
...

Now you can catch all the real errors and swallow all the exist code and so on.

See the exceptions handling in Python and embedding in general.

Categories: development, Myoddweb Piger Tags: