Forum OpenACS Development: NaviServer on windows - 6th of June

Dear all,
I would like to mention that if we take the latest developments of NaviServer, the system compiles and works properly till the version uploaded on the 6th of June. The following deliveries, though they compile, have stopped working.
I'm not sure why, but I saw many, many changes, especially in "tclhttp.c", associated to delivery with comment "Revamp of ns_http…".
Has anyone performed any regression testing on Windows (apart from me)?
Is it only me, or also you have noticed this anomaly in the new deliveries?

Thank you for your help.
Maurizio

Collapse
Posted by Maurizio Martignano on
Well, just to make an example, on bitbucket, the latest version, we have in include/ns.h

NS_EXTERN Ns_ReturnCode
Ns_SockListenCallback(const char *addr, unsigned short port, Ns_SockProc *proc, bool bind, void *arg)
NS_GNUC_NONNULL(3) NS_GNUC_NONNULL(5);

and in listen.c we have

NS_SOCKET
Ns_SockListenCallback(const char *addr, unsigned short port, Ns_SockProc *proc, bool bind, void *arg)
{
NS_SOCKET sock = NS_INVALID_SOCKET;
struct NS_SOCKADDR_STORAGE sa;
struct sockaddr *saPtr = (struct sockaddr *)&sa;

etc...

I really beg you to review all the changes that have been introduced since the 6th oh June.

All the best,
Maurizio

Collapse
Posted by Gustaf Neumann on
Dear Maurizio,

note that tip code of NaviServer on bitbucket is currently under some refactoring and is not a released code. The fact that does not work currently on windows is not due the discrepancy of the definition of Ns_SockListenCallback, the prototype was already incorrect since at least Dec 2017.

There is a major recfactoring and functional extension of ns_htttp, which is not finished yet. This will take still a few weeks of work depending on work loads.

The current code on the tip branch is regularly tested under Linux and macOS. but it was unknown to us that it is not functioning under windows. Many thanks for letting us know that. We do not have an ongoing testing for windows established. But certainly, windows testing and fixing has to be done before the next release of NaviServer.

Although i highly appreciate early testing of the code, please offer for your customers windows binaries of the last release tagged on bitbucket with "naviserver-4.99.18" (maybe additionally to snapshot compiles).

all the best
-gn

Collapse
Posted by Maurizio Martignano on
Hello Gustaf,
thank you for your answer.

Please ping me whenever the major refactoring is about to be finished, and I'll test it on Windows.

Thank you,
Maurizio

Collapse
Posted by Maurizio Martignano on
I believe I found the issue that has stopped NaviServer from working in Windows since the 12th of June.
Till the 12th of June in the file sock.c, function Ns_SockSendBufs2, there was a portion of code that was specific to Windows.

#ifdef _WIN32
{
DWORD bytesSent;
int rc;

rc = WSASend(sock, (LPWSABUF)bufs, nbufs, &bytesSent, flags,
NULL, NULL);
...

This portion has disappeared during the normalization/refactoring work.
Replacing the current sock.c file with the old one (6th of June, previous to the changes of the 12th) fixes the issue.
Best regards,
Maurizio

Collapse
Posted by Maurizio Martignano on

To be more precise the portion of Windows specific code has changed from:

#ifdef _WIN32
    {
        DWORD bytesSent;
        int   rc;

        rc = WSASend(sock, (LPWSABUF)bufs, nbufs, &bytesSent, flags,
                     NULL, NULL);
        if (rc == -1) {
            if (GetLastError() == WSAEWOULDBLOCK) {
                sent = 0;
            } else {
                sent = -1;
            }
        } else {
            sent = (ssize_t)bytesSent;
        }
    }
#else

to:

#ifdef _WIN32
    DWORD SendBytes = 0, Flags = (DWORD)flags;

    if (WSASend(sock, (LPWSABUF)bufs, (unsigned long)nbufs, &SendBytes,
                &Flags, NULL, NULL) == -1) {
        numBytes = -1;
    } else {
        numBytes = (ssize_t)SendBytes;
    }
#else

and the logic is not exactly the same.

Hope it helps, Maurizio

Collapse
Posted by Maurizio Martignano on

This is my last input on this topic, eventually I updated the latest version on the file sock.c with this modified function:

static ssize_t
SockSend(NS_SOCKET sock, struct iovec *bufs, int nbufs, unsigned int flags)
{
    ssize_t numBytes = 0;

#ifdef _WIN32
    DWORD SendBytes = 0, Flags = (DWORD)flags;
    int rc;

    rc = WSASend(sock, (LPWSABUF)bufs, (unsigned long)nbufs, &SendBytes, Flags, NULL, NULL);
    if (rc == -1) {
        if (GetLastError() == WSAEWOULDBLOCK) {
            numBytes = 0;
        }
        else {
            numBytes = -1;
        }
    } else {
        numBytes = (ssize_t)SendBytes;
    }
#else
    struct msghdr msg;

    memset(&msg, 0, sizeof(msg));
    msg.msg_iov = bufs;
    msg.msg_iovlen = (NS_MSG_IOVLEN_T)nbufs;
    numBytes = sendmsg(sock, &msg, (int)flags);
#endif

    if (numBytes == -1) {
        Ns_Log(Debug, "SockSend: %d, %s", sock, ns_sockstrerror(ns_sockerrno));
    }

    return numBytes;
}

Hope it helps, Maurizio

Collapse
Posted by Andrew Piskorski on
Gustaf, are there particular dates or commits of NaviServer that would be best for me to test and use on Windows? Or should I go ahead and use the tip (which you were still actively working on yesterday)?

I'm currently still using an older version from March, meaning I haven't even tested your 2019-05-22 Ns_NormalizePath vs. Ns_NormalizeUrl fix yet! So I should upgrade and test newer code soon, but I'm not sure which version is ready or best for that.

Collapse
Posted by Gustaf Neumann on
Although the version is in flux, i think the current version should be fine, as well under windows. Also openacs.org is running the tip version.
Collapse
Posted by Maurizio Martignano on
As far as I can tell everything is working fine also on Windows (13th of July).

The only issue that got me stuck for quite some time was that in the file sock.c there was a call to WSASend where the 5th parameter (Flags) that before refactoring was properly passed as value and after refactoring was passed as pointer. The issue has been fixed by Gustaf on the 4th of July.

Apart from that, everything seems to be OK.

Collapse
Posted by Andrew Piskorski on
On Windows, I'm using NaviServer from 2019-07-16, which seems to be working fine. I haven't yet tried any of the head code later than that.