--- /dev/null
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * Sleep Utils
+ *
+ * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SLEEP_UTILS_H
+#define __SLEEP_UTILS_H
+
+#include <freerdp/types.h>
+
+void freerdp_usleep(uint32 useconds);
+
+#endif /* __SLEEP_UTILS_H */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <freerdp/utils/sleep.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/hexdump.h>
if (status == 0 && transport->blocking)
{
- nanosleep(&transport->ts, NULL);
+ freerdp_usleep(transport->usleep_interval);
continue;
}
if (status == 0)
{
/* blocking while sending */
- nanosleep(&transport->ts, NULL);
+ freerdp_usleep(transport->usleep_interval);
/* when sending is blocked in nonblocking mode, the receiving buffer should be checked */
if (!transport->blocking)
transport->settings = settings;
/* a small 0.1ms delay when transport is blocking. */
- transport->ts.tv_sec = 0;
- transport->ts.tv_nsec = 100000;
+ transport->usleep_interval = 100;
/* receive buffer for non-blocking read. */
transport->recv_buffer = stream_new(BUFFER_SIZE);
struct rdp_tls* tls;
struct rdp_settings* settings;
struct rdp_credssp* credssp;
- struct timespec ts;
+ uint32 usleep_interval;
void* recv_extra;
STREAM* recv_buffer;
TransportRecv recv_callback;
profiler.c
rail.c
semaphore.c
+ sleep.c
stopwatch.c
stream.c
svc_plugin.c
--- /dev/null
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * Sleep Utils
+ *
+ * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <freerdp/utils/sleep.h>
+
+#define _XOPEN_SOURCE 500
+
+#include <time.h>
+#include <unistd.h>
+
+void freerdp_usleep(uint32 useconds)
+{
+ usleep(useconds);
+}
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <freerdp/utils/sleep.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/thread.h>
-#ifdef _WIN32
-#include <Windows.h>
-
-struct timespec
-{
- uint64 tv_sec;
- uint64 tv_nsec;
-};
-#endif
-
freerdp_thread* freerdp_thread_new(void)
{
freerdp_thread* thread;
{
int i = 0;
-#ifndef _WIN32
- struct timespec ts;
- ts.tv_sec = 0;
- ts.tv_nsec = 10000000;
-#else
- DWORD dwMilliseconds;
- dwMilliseconds = 10000;
-#endif
-
wait_obj_set(thread->signals[0]);
while (thread->status > 0 && i < 1000)
{
i++;
-#ifndef _WIN32
- nanosleep(&ts, NULL);
-#else
- SleepEx(dwMilliseconds, 0);
-#endif
+ freerdp_usleep(100);
}
for (i = 0; i < thread->num_signals; i++)