[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] Repeated calls to MHD_AccessHandlerCallback
From: |
Martin Bonner |
Subject: |
[libmicrohttpd] Repeated calls to MHD_AccessHandlerCallback |
Date: |
Thu, 5 Nov 2015 15:27:35 +0000 |
I have a question about the con_cls argument to MHD_AccessHandlerCallback.
Is it safe to assume that if *conCls is non-null, then the connection, url,
method, and version arguments will be unchanged from when *conCls _was_
null?
In other words, would a callback like the following be OK:
int AccessHandlerCallback( void *cls, MHD_Connection* connection,
const char* url, const char* method, const char* version,
const char* uploadData, size_t* uploadDatasize, void **conCls)
{
Session* session = (Session*)conCls;
if (!session)
*conCls = session = MakeSession( connection, url, method );
return HandleRequest(session, uploadData, uploadDatasize);
}
.. given that MakeSession stores its argument in the returned Session object.
(Yes, in reality, MakeSession is a C++ constructor, and HandleRequest is a
member function, but the principle is the same.)
Actually, there are two levels of guarantee. One is that the pointers and
the values they point at are unchanged. The second is that the strings
are always the same (but not necessarily at the same address) - in which
case I need to take a copy of the strings.
--
Martin Bonner
address@hidden
www.cst-gmbh.eu
- [libmicrohttpd] Repeated calls to MHD_AccessHandlerCallback,
Martin Bonner <=