Commit Graph

239 Commits

Author SHA1 Message Date
Marcelo Roberto Jimenez
96112229a5 Homekeeping to match the stable branch release. 2011-11-14 13:05:51 -02:00
Fabrice Fontaine
4b82bb7baf UPnP Low Power support
Adding two new functions (UpnpSendAdvertisementLowPower and
UpnpUnRegisterRootDeviceLowPower) which can be used to specify values
for the three SSDP headers defined by UPnP Low Power. Those headers are
Powerstate, SleepPeriod and RegistrationState.
(cherry picked from commit 98e4f938d6)
2011-11-04 20:34:00 -02:00
Fabrice Fontaine
c86d963abe Bug fix in IN6_IS_ADDR_GLOBAL.
Changing IN6_IS_ADDR_GLOBAL to accept all IPv6 addresses which have a
2000::/3 prefix.
(cherry picked from commit 92c93a8010)
2011-11-01 19:02:15 -02:00
Fabrice Fontaine
5cf603dcab Bug Fix on M-SEARCH.
Do not answer to M-SEARCH using HTTP version 1.0 as specified by the
UPnP Device Architecture.
(cherry picked from commit 6c6fb3707f)
2011-07-20 06:24:21 -03:00
Iain Denniston
259bed7787 Fixes for compilation under Windows (specifically MSVC). Also added MSVC supported "_inline", and fixed some WIN32 specific warnings.
(cherry picked from commit 92ea719804)
2011-04-02 23:50:36 -03:00
Iain Denniston
7392697aec Several fixes to correctly use SOCKET (and related) types instead of non-portable variations.
(cherry picked from commit fed316ff3e)
2011-04-02 23:50:25 -03:00
Marcelo Roberto Jimenez
f8831d0196 Homekeeping for the stable branch release. 2011-03-17 09:40:28 -03:00
Fabrice Fontaine
babfc0ac60 Putting ssdpReqSocks under compilation flag.
Putting all access to ssdpReqSock4 and ssdpReqSock6 under
INCLUDE_CLIENT_APIS compilation flag to be able to compile when
client part of library is disable.
(cherry picked from commit 0996d23318)
2011-03-15 18:58:51 -03:00
Fabrice Fontaine
daec6a0321 New UpnpRegisterRootDevice4 for legacy CPs.
Add a new UpnpRegisterRootDevice4 which allow user to specify a
description URL to be returned for legacy CPs (for example, CPs
searching for a v1 when the device is v2). Most of those CPs does not
work if they found a v2 in the XML description, so this new function is
only used to solve interoperability issues.
(cherry picked from commit 11f9a2bafe)
2011-03-15 18:19:59 -03:00
Iain Denniston
bbe6d49b46 Fix for memory leak
(cherry picked from commit 8aca337de7)
2011-03-11 18:35:30 -03:00
Iain Denniston
d691732554 Fix and Update of MSVC9 solution and project files
(cherry picked from commit a78a048577)
2011-03-11 18:08:11 -03:00
Iain Denniston
fed2e4f8e5 Partial fix for UpnpGetIfInfo with MSVC
(cherry picked from commit 7338411c08)
2011-03-11 17:59:39 -03:00
Marcelo Roberto Jimenez
a3683a3be0 Created the macros PRIzd and PRIzx to deal with MSVC lack of C99.
Thanks to Iain Denniston for pointing it out.
(cherry picked from commit 3a9ae348bc)
2011-03-11 17:21:18 -03:00
Iain Denniston
a1d7727903 Fixes for headers when compiled under C++
(cherry picked from commit 840669b253)
2011-03-11 16:11:19 -03:00
Marcelo Roberto Jimenez
1df5609d52 Fix for uuid_unpack incorrect shift precedence. 2011-03-10 16:26:11 -03:00
Marcelo Roberto Jimenez
5a8aec58aa Changelog update. 2011-02-08 21:55:13 -02:00
Marcelo Roberto Jimenez
b6baca8eb0 Remove PrintThreadPoolStats() from the public API.
This function uses a ThreadPool object as an argument, which is not
supposed to be exported. Also, debug compilation was broken.
(cherry picked from commit 32e510b45a)
2011-02-07 22:43:40 -02:00
Fabrice Fontaine
28f4d398d8 Major bug fix in IPv6 code.
Major bug fix in miniserver.c for IPv6, bug was introduced when
changing implementation of get_port in November 20th 2010 ("gena:fix
several compiler warnings" commit).
(cherry picked from commit 063d472f80)
2011-02-07 21:28:08 -02:00
Marcelo Roberto Jimenez
ee9f83c3d5 Fix for incorrectly exported include files.
The files FreeList.h, LinkedList.h, ThreadPool.h and TimerThread.h
from the threautil library were being installed in the include
directory of the library, incorrectly exposing internal data structure
of the library.
(cherry picked from commit 0bbe9f62df)
2011-02-06 11:55:04 -02:00
Chandra Penke
40239ca44a Fix for compilation errors
Fix for compilation warnings of unused variables in upnpdebug.c in
release builds.
(cherry picked from commit 6c125feea0)
2011-01-30 09:43:00 -02:00
Chandra Penke
a2eca3b19d Fix for Race condition can hang miniserver thread.
Add 'requiredThreads' field to the ThreadPool structure, to avoid
a race condition when waiting for a new thread to be created. The
race condition occurs when a thread is destroyed while the master
thread is waiting for a new thread to be created.

Thanks to Chuck Thomason for pointing the problem.

Summary: Race condition can hang miniserver thread - ID: 3158591

Details:
Hello,

I have found a race condition in the thread pool handling of
libupnp-1.6.6 that periodically results in the miniserver thread
getting blocked infinitely.

In my setup, I have the miniserver thread pool configured with 1
job per thread, 2 threads minimum, and 50 threads maximum.

Just before the lockup occurs, the miniserver thread pool contains
2 threads: one worker thread hanging around from a previous HTTP
request job (let's call that thread "old_worker") and the
miniserver thread itself.

A new HTTP request comes in. Accordingly, the miniserver enters
schedule_request_job() and then ThreadPoolAdd(). In
ThreadPoolAdd(), the job gets added to the medium-priority queue,
and AddWorker() is called. In AddWorker(), jobs = 1 and threads =
1, so CreateWorker gets called.

When we enter CreateWorker(), tp->totalThreads is 2, so
currentThreads is 3. The function creates a new thread and then
blocks on tp->start_and_shutdown. The miniserver thread expects
the newly created thread to increment tp->totalThreads and then
signal the condition variable to wake up the miniserver thread and
let it proceed.

The newly created thread starts in the WorkerThread() function. It
increments tp->totalThreads to 3, does a broadcast on the
start_and_shutdown condition, and starts running its job. However,
before the miniserver thread wakes up, "old_worker" times out. It
sees that there are no jobs in any queue and that the total number
of threads (3) is more than the minimum (2). As a result, it
reduces tp->totalThreads to 2 and dies.

Now the miniserver thread finally wakes up. It checks
tp->totalThreads and sees that its value is 2, so it blocks on
tp->start_and_shutdown again. It has now "missed" seeing
tp->totalThreads get incremented to 3 and will never be unblocked
again.

When this issue does occur for a server device, the miniserver
port remains open, but becomes unresponsive since the miniserver
thread is stuck. SSDP alive messages keep getting sent out, as
they are handled by a separate thread. Reproducing the issue is
difficult due to the timing coincidence involved, but in my
environment I am presently seeing it at least once a day. I
figured out the sequence described above through addition of my
own debug logs.

The relevant code involved in this bug has not changed
substantially in libupnp-1.6.10, though I am planning to test
against 1.6.10 as well in the near future.

Do you have any input for an elegant fix for this issue?

Thanks,

Chuck Thomason
(cherry picked from commit c4e9757bcf)
2011-01-20 04:46:57 -02:00
Chandra Penke
1a574ed6cf Fix for large file definitions, FileInfo.h must include upnpconfig.h 2011-01-17 08:55:57 -02:00
Marcelo Roberto Jimenez
7dae12f17d Fix some ChangeLog dates. 2011-01-17 08:40:00 -02:00
Chandra Penke
bf30519f6c Fix for warnings in Apple systems 2011-01-17 08:18:32 -02:00
Marcelo Roberto Jimenez
bdb3f880b7 Define _FILE_OFFSET_BITS, _LARGEFILE_SOURCE and _LARGE_FILE_SOURCE in upnpconfig.h.
Make these definitions available to programs using the library.
Thanks to Chandra Penke for pointing the problem.
(cherry picked from commit abfa841318)
2011-01-16 22:39:37 -02:00
Marcelo Roberto Jimenez
348bf19412 Use config.h to test for the availability of strndup() and strnlen().
(cherry picked from commit 541679d651)
2011-01-16 21:06:00 -02:00
Marcelo Roberto Jimenez
60c9e95637 Fix for UpnpFileInfo_get_LastModified() in http_MakeMessage().
UpnpFileInfo_get_LastModified() returns time_t, and http_MakeMessage()
takes a "time_t *". Thanks to Chandra Penke for pointing the bug.
2011-01-16 15:09:01 -02:00
Chandra Penke
1e2172819d Fixes chunked transfer encoding in HTTP client API
(cherry picked from commit cb1188d2bc)
2011-01-15 21:14:00 -02:00
Marcelo Roberto Jimenez
6333504d45 Null termination of strndup() implementation on systems missing it.
Also, implementation of strnlen() on systems missing it.
(cherry picked from commit 189ce59dbe)
2011-01-14 22:06:26 -02:00
Marcelo Roberto Jimenez
9d667685ec Minor change in membuffer.c to include "membuffer.h"
...without looking in the standard header path. This allows pupnp
to build in xcode.
(cherry picked from commit 9051731a93)
2011-01-14 10:28:23 -02:00
Marcelo Roberto Jimenez
3ad98ad746 SF Tracker: Patches - Fedora mingw32 compilation - ID: 3138849
Details:
Hello. I trying compile libupnp-1.6.10 on the Fedora 14 MinGW
Environment and get many errors. I create patch to fix it. With this
patch i can get static library. This patch is very raw.

Submitted: Ivan Romanov (ivanromanov) - 2010-12-16 23:29:19 UTC
(cherry picked from commit b2a88aa70b)
2010-12-19 19:10:44 -02:00
Marcelo Roberto Jimenez
ad0584150f Changelog fix from 1.6.x. 2010-12-11 16:53:32 -02:00
Fabrice Fontaine
57e9584f4e Major bug fix in http_SendMessage.
Currently, http_SendMessage was not able to write to write a buffer
due to a bad use of file_buf instead of buf. This bug was introduced by
the 0197-Doxygen-reformating-compiler-warnings patch.
(cherry picked from commit 2c3bce13bd)
2010-11-24 11:54:54 -02:00
Fabrice Fontaine
86783f0329 Returning the SID in Upnp_Event_Subscribe.
Currently, Upnp_Event_Subscribe always contains an empty chain in the
Sid parameter. This patch now saves the client Subscription ID in this
parameter so Control Points can see and use the same SID in the
Upnp_Event_Subscribe and in the Upnp_Event structures.
2010-11-24 11:54:24 -02:00
Juergen Lock
25641ac51a Two fixes from Juergen Lock <nox(at)jelal.kn-bremen.de>:
1. varargs:  pass size of CRLF as size_t not as int:

--- upnp/src/gena/gena_device.c.orig
+++ upnp/src/gena/gena_device.c
@@ -225,7 +225,7 @@ static UPNP_INLINE int notify_send_and_r
		"bbb",
		start_msg.buf, start_msg.length,
		propertySet, strlen(propertySet),
-		"\r\n", 2);
+		"\r\n", sizeof "\r\n" - 1);
	if (ret_code) {
		membuffer_destroy(&start_msg);
		sock_destroy(&info, SD_BOTH);

2. Remove "b" arg here, there is no buffer passed:  (this caused a pointer
to be interpreted as a buffer size to be alloc'd/copied, hence the 32 GB.)

--- upnp/src/genlib/net/http/webserver.c.orig
+++ upnp/src/genlib/net/http/webserver.c
@@ -1262,7 +1262,7 @@ static int process_request(
			// Content-Range: bytes 222-3333/4000  HTTP_PARTIAL_CONTENT
			// Transfer-Encoding: chunked
			if (http_MakeMessage(headers, resp_major, resp_minor,
-				"R" "TLD" "s" "tcS" "b" "Xc" "sCc",
+				"R" "TLD" "s" "tcS" "Xc" "sCc",
				HTTP_OK,    // status code
				finfo.content_type, // content type
				RespInstr,  // language info
(cherry picked from commit ed0ebe1588)
2010-11-22 23:29:28 -02:00
Marcelo Roberto Jimenez
f260a0e9d6 Template object for ssdp_ResultData. 2010-11-22 10:22:06 -02:00
Marcelo Roberto Jimenez
dd2624ebfe Added the convenience function UpnpResolveURL2() to upnptools.c.
This function avoids some unecessary memory allocation.
The memory alloc'd by this function must be freed later by the caller.
(cherry picked from commit 8651174861)
2010-11-15 01:02:07 -02:00
Fabrice Fontaine
b0cab00ca3 Add GENA_NOTIFICATION_xxx_TIMEOUT variable.
Currently, in notify_send_and_recv function, pupnp waits for
HTTP_DEFAULT_TIMEOUT seconds when trying to send a GENA notification.
When there is a lot of notifications with CPs which was disconnected
without unsusbcribing, all the pupnp threads are blocked on this
timeout. To correct, this issue, this patch adds a new variable,
GENA_NOTIFICATION_SENDING_TIMEOUT, which can be used to lower the
timeout so GENA threads return quickly when writing is impossible. By
the same mean, pupnp waits the CP's answer to the NOTIFY for
HTTP_DEFAULT_TIMEOUT seconds, so this patch adds a new variable,
GENA_NOTIFICATION_ANSWERING_TIMEOUT, to customize this value.
(cherry picked from commit e6c548f57a)
2010-11-11 21:44:10 -02:00
Fabrice Fontaine
8811bf7ede Add --disable-blocking-tcp-connections flag.
Currently, pupnp is using a blocking connect to sends GENA
notifications. As a result, when there is a lot of notifications with
CPs which were disconnected without unsusbcribing, all the pupnp
threads are blocked for 20s (timeout). To correct this issue, this
patch replace the call to connect with a call to private_connect and add
a compilation flag to disable blocking TCP connections, so if we are not
able to connect to the CP, the notification is lost.
(cherry picked from commit 32cffb5bb5)
2010-11-11 21:43:55 -02:00
Fabrice Fontaine
6c64b7eeb5 Support for "polling" select in sock_read_write.
Currently, in sock_read_write function, if the timeout is 0, pupnp
realizes a "blocking" select (with an infinite timeout). With this
patch, if timeout is set to 0, pupnp will realize a "polling" select
and returns immediately if it can not read or write on the socket. This
is very useful for GENA notifications when pupnp is trying to send
events to a disconnected Control Point. "Blocking" select can now be
done by putting a negative timeout value.
2010-11-11 21:24:49 -02:00
Marcelo Roberto Jimenez
1fd443f79f Changelog and THANKS update.
(cherry picked from commit d32212a6fd)
2010-11-07 19:21:20 -02:00
Marcelo Roberto Jimenez
843b255518 PTHREAD_MUTEX_RECURSIVE on DragonFly is an enum.
SF Bug Tracker - ID: 3104527
Submitted: OBATA Akio ( obache ) - 2010-11-07 07:10:28 BRST

In threadutil/inc/ithread.h, it is expected that
PTHREAD_MUTEX_RECURSIVE is defined as macro. But on DragonFly BSD,
it is defined as enum, so not works as expected.

Attachment patch treat that DragonFly BSD always
have PTHREAD_MUTEX_RECURSIVE.
(cherry picked from commit ff006272b5)
2010-11-07 11:50:27 -02:00
Marcelo Roberto Jimenez
8196092f50 ftime(3) in -lcompat should not be checked.
SF Bug Tracker - ID: 3104521
Submitted: OBATA Akio ( obache ) - 2010-11-07 07:03:44 BRST

In configure.ac
AC_CHECK_FUNCS(ftime,, [AC_CHECK_LIB(compat, ftime)])

But since version 1.6.3, ftime(3) is not used, so it should be
removed, or introduce unwanted linkage with -lcompat.
(cherry picked from commit 852c301c5c)
2010-11-07 09:46:22 -02:00
Marcelo Roberto Jimenez
b6007d54d8 Changelog adjust because of new 1.6.x release. 2010-11-07 01:45:53 -02:00
Marcelo Roberto Jimenez
b59ec7d838 Fix for "SampleUtil_Initialize was called multiple times!" bug.
Fix for bug introduced in samples code in svn revision 502, commit
git:25c908c558c8e60eb386c155a6b93add447ffec0

Sample device and combo were aborting with the message:
"***** SampleUtil_Initialize was called multiple times!"
(cherry picked from commit ef7edf6cf8)
2010-11-06 00:46:58 -02:00
Fabrice Fontaine
8e0c92a52a Make multiple SSDP advertisements faster.
Put the loop to send multiple copies of each SSDP advertisements in
ssdp_server.c instead of ssdp_device.c so we have only one call to
imillisleep ( SSDP_PAUSE ) to speed up advertisements.
(cherry picked from commit c65ec8a720)
2010-11-05 23:54:04 -02:00
Fabrice Fontaine
56e0fdd438 Removing unused NUM_COPY variable.
Previously, NUM_COPY was used in ssdp_device.c to send multiple copies
of each advertisements but also multiple replies to each M-SEARCH
request. As sending multiple replies is not compliant with HTTPU/MU
spec, NUM_COPY has been set to 1 in an older patch. However, as this
variable is not needed and has been replaced with SSDP_COPY, it has
been removed.
(cherry picked from commit 2d22e997e1)
2010-11-05 23:53:55 -02:00
Fabrice Fontaine
b8b5f6a0ef Use SSDP_COPY to send multiple SSDP advertisements.
Currently, SSDP_COPY is used only to send multiple M-SEARCH requests (in
ssdp_ctrlpt.c). With this patch, SSDP_COPY is also used to send multiple
copies of each advertisements packets (in ssdp_device.c).
(cherry picked from commit 96dc968f18)
2010-11-05 13:29:35 -02:00
Carl Benson
4d37927c64 patch for taking notice of UPNP_USE_RWLOCK flag in threadutil
By "Carl Benson" <carl.benson@windriver.com>:

I had to do some modifications myself though, because the Android
build system insists on having a file named "util.h" taking precedence
in its include path, libupnp gets confused because of the same filename
in upnp/src/inc/util.h

(hand cherry picked from commit 8e846368e0)
2010-11-01 01:11:21 -02:00
Marcelo Roberto Jimenez
b67c321869 Fix a long date memory leak in webserver.c:StrStr().
(cherry picked from commit bf1450bf81)
2010-10-20 01:44:56 -02:00