Merge pull request #1314 from nfedera/fix-2013-06-24-01
sample server: support build on win32
This commit is contained in:
commit
f670bce3c5
@ -19,11 +19,11 @@
|
||||
|
||||
add_subdirectory(common)
|
||||
|
||||
if(NOT WIN32)
|
||||
if(WITH_SAMPLE)
|
||||
add_subdirectory(Sample)
|
||||
endif()
|
||||
if(WITH_SAMPLE)
|
||||
add_subdirectory(Sample)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
if(WITH_X11)
|
||||
add_subdirectory(X11)
|
||||
endif()
|
||||
|
@ -26,14 +26,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp/server/rdpsnd.h>
|
||||
|
||||
#include "sf_audin.h"
|
||||
@ -41,7 +40,7 @@
|
||||
|
||||
#include "sfreerdp.h"
|
||||
|
||||
#define SAMPLE_SERVER_USE_CLIENT_RESOLUTION 0
|
||||
#define SAMPLE_SERVER_USE_CLIENT_RESOLUTION 1
|
||||
#define SAMPLE_SERVER_DEFAULT_WIDTH 1024
|
||||
#define SAMPLE_SERVER_DEFAULT_HEIGHT 768
|
||||
|
||||
@ -569,9 +568,11 @@ void tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
}
|
||||
else
|
||||
{
|
||||
client->settings->DesktopWidth = 640;
|
||||
client->settings->DesktopHeight = 480;
|
||||
client->settings->DesktopWidth = SAMPLE_SERVER_DEFAULT_WIDTH;
|
||||
client->settings->DesktopHeight = SAMPLE_SERVER_DEFAULT_HEIGHT;
|
||||
}
|
||||
context->rfx_context->width = client->settings->DesktopWidth;
|
||||
context->rfx_context->height = client->settings->DesktopHeight;
|
||||
update->DesktopResize(update->context);
|
||||
context->activated = FALSE;
|
||||
}
|
||||
@ -698,7 +699,11 @@ static void* test_peer_mainloop(void* arg)
|
||||
printf("Failed to get FreeRDP file descriptor\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/* winsock's select() only works with sockets ! */
|
||||
WTSVirtualChannelManagerGetFileDescriptor(context->vcm, rfds, &rcount);
|
||||
#endif
|
||||
|
||||
max_fds = 0;
|
||||
FD_ZERO(&rfds_set);
|
||||
@ -718,15 +723,27 @@ static void* test_peer_mainloop(void* arg)
|
||||
|
||||
if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* error codes set by windows sockets are not made available through errno ! */
|
||||
int wsa_error = WSAGetLastError();
|
||||
if (!((wsa_error == WSAEWOULDBLOCK) ||
|
||||
(wsa_error == WSAEINPROGRESS) ||
|
||||
(wsa_error == WSAEINTR)))
|
||||
{
|
||||
printf("select failed (WSAGetLastError: %d)\n", wsa_error);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
/* these are not really errors */
|
||||
if (!((errno == EAGAIN) ||
|
||||
(errno == EWOULDBLOCK) ||
|
||||
(errno == EINPROGRESS) ||
|
||||
(errno == EINTR))) /* signal occurred */
|
||||
{
|
||||
printf("select failed\n");
|
||||
printf("select failed (errno: %d)\n", errno);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (client->CheckFileDescriptor(client) != TRUE)
|
||||
@ -747,10 +764,10 @@ static void* test_peer_mainloop(void* arg)
|
||||
|
||||
static void test_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
|
||||
{
|
||||
pthread_t th;
|
||||
|
||||
pthread_create(&th, 0, test_peer_mainloop, client);
|
||||
pthread_detach(th);
|
||||
HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_peer_mainloop, (void*) client, 0, NULL);
|
||||
if (hThread != NULL) {
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_server_mainloop(freerdp_listener* instance)
|
||||
@ -817,9 +834,6 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
freerdp_listener* instance;
|
||||
|
||||
/* Ignore SIGPIPE, otherwise an SSL_write failure could crash your server */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
instance = freerdp_listener_new();
|
||||
|
||||
instance->PeerAccepted = test_peer_accepted;
|
||||
@ -831,12 +845,14 @@ int main(int argc, char* argv[])
|
||||
test_dump_rfx_realtime = FALSE;
|
||||
|
||||
/* Open the server socket and start listening. */
|
||||
freerdp_wsa_startup();
|
||||
if (instance->Open(instance, NULL, 3389) &&
|
||||
instance->OpenLocal(instance, "/tmp/tfreerdp-server.0"))
|
||||
{
|
||||
/* Entering the server main loop. In a real server the listener can be run in its own thread. */
|
||||
test_server_mainloop(instance);
|
||||
}
|
||||
freerdp_wsa_cleanup();
|
||||
|
||||
freerdp_listener_free(instance);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user