mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-11 05:43:33 +00:00
1. Fixed edge case bug, where TLS packet was corrupt
2. Added compile switch for KVM ALL TILES 3. Added compile switch for Debug fragmentation of Sends 4. Fixed compiler warnings 5. Added comments to makefile
This commit is contained in:
32
makefile
32
makefile
@@ -82,6 +82,29 @@
|
||||
# gmake freebsd ARCHID=31 # Reserved for FreeBSD x86 32 bit
|
||||
|
||||
|
||||
#
|
||||
# Required build switches:
|
||||
# ARCHID Architecture ID
|
||||
#
|
||||
#
|
||||
# Optional build switches:
|
||||
# DEBUG 0 = Release, 1 = DEBUG => Default is Release
|
||||
# FSWATCH_DISABLE 1 = Remove fswatchter support => Default is fswatcher supported
|
||||
# IPADDR_MONITOR_DISABLE 1 = No IPAddress Monitoring => Default is IPAddress Monitoring Enabled
|
||||
# IFADDR_DISABLE 1 = Don't use ifaddrs.h => Default is use IFADDR
|
||||
# KVM 1 = KVM Enabled, 0 = KVM Disabled => Default depends on ARCHID
|
||||
# KVM_ALL_TILES 0 = Normal, 1 = All Tiles => Default is Normal Tiling Algorithm
|
||||
# LEGACY_LD 0 = Standard, 1 = Legacy => Default is Standard (CentOS 5.11 requires Legacy)
|
||||
# NET_SEND_FORCE_FRAGMENT 1 = net.send() fragments sends => Default is normal send operation
|
||||
# NOTLS 1 = TLS Support Compiled Out => Default is TLS Support Compiled In
|
||||
# NOTURBOJPEG 1 = Don't use Turbo JPEG => Default is USE TurboJPEG
|
||||
# SSL_EXPORTABLE_KEYS 1 = Export SSL Keys for debugging => Default is DO NOT export SSL keys
|
||||
# TLS_WRITE_TRACE 1 = Enable TLS Send Tracing => Default is tracing disabled
|
||||
# WatchDog WatchDog timer interval. => Default is 6000000
|
||||
# WEBLOG 1 = Enable WebLogging Interface => Default is disabled
|
||||
# WEBRTCDEBUG 1 = Enable WebRTC Instrumentation => Default is disabled
|
||||
#
|
||||
|
||||
# Microstack & Microscript
|
||||
SOURCES = microstack/ILibAsyncServerSocket.c microstack/ILibAsyncSocket.c microstack/ILibAsyncUDPSocket.c microstack/ILibParsers.c microstack/ILibMulticastSocket.c
|
||||
SOURCES += microstack/ILibRemoteLogging.c microstack/ILibWebClient.c microstack/ILibWebRTC.c microstack/ILibWebServer.c microstack/ILibCrypto.c
|
||||
@@ -390,6 +413,15 @@ ifeq ($(TLS_WRITE_TRACE),1)
|
||||
CFLAGS += -D_TLSLOG
|
||||
endif
|
||||
|
||||
ifeq ($(NET_SEND_FORCE_FRAGMENT),1)
|
||||
CFLAGS += -D_DEBUG_NET_FRAGMENT_SEND
|
||||
endif
|
||||
|
||||
ifeq ($(KVM_ALL_TILES),1)
|
||||
CFLAGS += -DKVM_ALL_TILES
|
||||
endif
|
||||
|
||||
|
||||
GCCTEST := $(shell $(CC) meshcore/dummy.c -o /dev/null -no-pie > /dev/null 2>&1 ; echo $$? )
|
||||
ifeq ($(GCCTEST),0)
|
||||
LDFLAGS += -no-pie
|
||||
|
||||
@@ -899,9 +899,14 @@ void* kvm_server_mainloop(void* parm)
|
||||
}
|
||||
ILibQueue_UnLock(g_messageQ);
|
||||
|
||||
for (r = 0; r < TILE_HEIGHT_COUNT; r++) {
|
||||
for (c = 0; c < TILE_WIDTH_COUNT; c++) {
|
||||
for (r = 0; r < TILE_HEIGHT_COUNT; r++)
|
||||
{
|
||||
for (c = 0; c < TILE_WIDTH_COUNT; c++)
|
||||
{
|
||||
g_tileInfo[r][c].flag = TILE_TODO;
|
||||
#ifdef KVM_ALL_TILES
|
||||
g_tileInfo[r][c].crc = 0xFF;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
//fprintf(logFile, "Before CheckDesktopSwitch.\n"); fflush(logFile);
|
||||
|
||||
@@ -28,6 +28,12 @@ limitations under the License.
|
||||
|
||||
int KVM_Listener_FD = -1;
|
||||
#define KVM_Listener_Path "/usr/local/mesh_services/meshagent/kvm"
|
||||
#if defined(_TLSLOG)
|
||||
#define TLSLOG1 printf
|
||||
#else
|
||||
#define TLSLOG1(...) ;
|
||||
#endif
|
||||
|
||||
|
||||
int KVM_AGENT_FD = -1;
|
||||
int KVM_SEND(char *buffer, int bufferLen)
|
||||
@@ -488,12 +494,17 @@ void* kvm_server_mainloop(void* param)
|
||||
ILibQueue_UnLock(g_messageQ);
|
||||
|
||||
|
||||
for (r = 0; r < TILE_HEIGHT_COUNT; r++) {
|
||||
for (c = 0; c < TILE_WIDTH_COUNT; c++) {
|
||||
for (r = 0; r < TILE_HEIGHT_COUNT; r++)
|
||||
{
|
||||
for (c = 0; c < TILE_WIDTH_COUNT; c++)
|
||||
{
|
||||
g_tileInfo[r][c].flag = TILE_TODO;
|
||||
#ifdef KVM_ALL_TILES
|
||||
g_tileInfo[r][c].crc = 0xFF;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
//senddebug(2);
|
||||
|
||||
screen_num = CGMainDisplayID();
|
||||
|
||||
if (screen_num == 0) { g_shutdown = 1; senddebug(-2); break; }
|
||||
@@ -538,8 +549,6 @@ void* kvm_server_mainloop(void* param)
|
||||
fsync(STDOUT_FILENO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (y = 0; y < TILE_HEIGHT_COUNT; y++)
|
||||
{
|
||||
for (x = 0; x < TILE_WIDTH_COUNT; x++) {
|
||||
@@ -642,7 +651,9 @@ void kvm_relay_StdOutHandler(ILibProcessPipe_Process sender, char *buffer, int b
|
||||
if (bufferLen >= (8 + (int)ntohl(((unsigned int*)(buffer))[1])))
|
||||
{
|
||||
*bytesConsumed = 8 + (int)ntohl(((unsigned int*)(buffer))[1]);
|
||||
TLSLOG1("<< KVM/WRITE: %d bytes\n", *bytesConsumed);
|
||||
writeHandler(buffer, *bytesConsumed, reserved);
|
||||
|
||||
//printf("JUMBO PACKET: %d\n", *bytesConsumed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -325,11 +325,12 @@ int getTileAt(int x, int y, void** buffer, long long *bufferSize, void *desktop,
|
||||
}
|
||||
|
||||
int retval = 0;
|
||||
int firstTime = 1;
|
||||
|
||||
#if MAX_TILE_SIZE == 0
|
||||
retval = calc_opt_compr_send(x, y, captureWidth, captureHeight, desktop, desktopsize, buffer, bufferSize);
|
||||
#else
|
||||
int firstTime = 1;
|
||||
|
||||
//This loop is used to adjust the COMPRESSION_RATIO. This loop runs only once most of the time.
|
||||
do {
|
||||
//retval here is 0 if everything was good. It is > 0 if it contains the size of the jpeg that was created and not sent.
|
||||
@@ -389,7 +390,8 @@ int getTileAt(int x, int y, void** buffer, long long *bufferSize, void *desktop,
|
||||
jpeg_buffer_length = 0;
|
||||
|
||||
for (r = row; r <= botrow; r++) {
|
||||
for (c = col; c <= rightcol; c++) {
|
||||
for (c = col; c <= rightcol; c++)
|
||||
{
|
||||
g_tileInfo[r][c].flag = TILE_SENT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -901,9 +901,14 @@ DWORD WINAPI kvm_server_mainloop_ex(LPVOID parm)
|
||||
KVMDEBUG("kvm_server_mainloop / loop1", (int)GetCurrentThreadId());
|
||||
|
||||
// Reset all the flags to TILE_TODO
|
||||
for (row = 0; row < TILE_HEIGHT_COUNT; row++) {
|
||||
for (col = 0; col < TILE_WIDTH_COUNT; col++) {
|
||||
for (row = 0; row < TILE_HEIGHT_COUNT; row++)
|
||||
{
|
||||
for (col = 0; col < TILE_WIDTH_COUNT; col++)
|
||||
{
|
||||
tileInfo[row][col].flags = (char)TILE_TODO;
|
||||
#ifdef KVM_ALL_TILES
|
||||
tileInfo[row][col].crc = 0xFF;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
CheckDesktopSwitch(1, writeHandler, reserved);
|
||||
|
||||
@@ -251,7 +251,15 @@ void ILibDuktape_net_socket_OnSendOK(ILibAsyncSocket_SocketModule socketModule,
|
||||
ILibTransport_DoneState ILibDuktape_net_socket_WriteHandler(ILibDuktape_DuplexStream *stream, char *buffer, int bufferLen, void *user)
|
||||
{
|
||||
ILibDuktape_net_socket *ptrs = (ILibDuktape_net_socket*)user;
|
||||
#ifdef _DEBUG_NET_FRAGMENT_SEND
|
||||
int x = bufferLen / 2;
|
||||
printf("** Send 1/2: %d of %d bytes\n", x, bufferLen);
|
||||
ILibAsyncSocket_Send(ptrs->socketModule, buffer, x, ILibAsyncSocket_MemoryOwnership_USER);
|
||||
printf("** Send 2/2: %d of %d bytes\n", bufferLen - x, bufferLen);
|
||||
return((ILibTransport_DoneState)ILibAsyncSocket_Send(ptrs->socketModule, buffer + x, bufferLen - x, ILibAsyncSocket_MemoryOwnership_USER));
|
||||
#else
|
||||
return((ILibTransport_DoneState)ILibAsyncSocket_Send(ptrs->socketModule, buffer, bufferLen, ILibAsyncSocket_MemoryOwnership_USER));
|
||||
#endif
|
||||
}
|
||||
void ILibDuktape_net_socket_EndHandler(ILibDuktape_DuplexStream *stream, void *user)
|
||||
{
|
||||
|
||||
@@ -606,6 +606,10 @@ ILibAsyncSocket_SendStatus ILibAsyncSocket_SendTo_MultiWrite(ILibAsyncSocket_Soc
|
||||
|
||||
ignore_result(BIO_reset(module->writeBio));
|
||||
}
|
||||
else if (bytesSent < 0)
|
||||
{
|
||||
TLSLOG1(" -- > [INCOMPLETE] Accumulated into BIOBUFFER[%d]\n", module->internalSocket);
|
||||
}
|
||||
retVal = ILibAsyncSocket_NOT_ALL_DATA_SENT_YET;
|
||||
}
|
||||
else if (bytesSent == module->writeBioBuffer->length)
|
||||
@@ -634,7 +638,7 @@ ILibAsyncSocket_SendStatus ILibAsyncSocket_SendTo_MultiWrite(ILibAsyncSocket_Soc
|
||||
// Send will happen in ILibAsyncSocket_PostSelect()
|
||||
retVal = ILibAsyncSocket_NOT_ALL_DATA_SENT_YET;
|
||||
module->PendingBytesToSend = (unsigned int)(module->writeBioBuffer->length);
|
||||
TLSLOG1(" --> Accumulate[%d]...\n", module->internalSocket);
|
||||
TLSLOG1(" --> [IN PROGRESS] Accumulated into BIOBUFFER[%d]...\n", module->internalSocket);
|
||||
}
|
||||
|
||||
if (lockOverride == 0) { sem_post(&(module->SendLock)); }
|
||||
@@ -1883,7 +1887,14 @@ void ILibAsyncSocket_PostSelect(void* socketModule, int slct, fd_set *readset, f
|
||||
}
|
||||
else
|
||||
{
|
||||
TLSLOG1(" --> REMAINING: %d bytes --<\n", module->PendingSend_Head->bufferSize - module->PendingSend_Head->bytesSent);
|
||||
if (module->PendingSend_Head->bufferSize - module->PendingSend_Head->bytesSent == 0 && module->PendingSend_Head->UserFree == ILibAsyncSocket_MemoryOwnership_BIO)
|
||||
{
|
||||
TLSLOG1(" --> DRAINED (BIOBUFFER still has %d bytes)\n", (int)(module->writeBioBuffer->length));
|
||||
}
|
||||
else
|
||||
{
|
||||
TLSLOG1(" --> REMAINING: %d bytes --<\n", module->PendingSend_Head->bufferSize - module->PendingSend_Head->bytesSent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bytesSent <= 0)
|
||||
@@ -1901,7 +1912,7 @@ void ILibAsyncSocket_PostSelect(void* socketModule, int slct, fd_set *readset, f
|
||||
{
|
||||
BIO_clear_retry_flags(module->writeBio);
|
||||
bytesSent = (int)send(module->internalSocket, module->writeBioBuffer->data, (int)(module->writeBioBuffer->length), MSG_NOSIGNAL); // Klocwork reports that this could block while holding a lock... This socket has been set to O_NONBLOCK, so that will never happen
|
||||
TLSLOG1(" << Accumulated Drain[%d]: %d bytes >>\n", module->internalSocket, bytesSent);
|
||||
TLSLOG1(" << BIOBUFFER[%d] drain: %d of %d bytes >>\n", module->internalSocket, bytesSent, (int)module->writeBioBuffer->length);
|
||||
#ifdef WIN32
|
||||
if ((bytesSent > 0 && bytesSent < (int)(module->writeBioBuffer->length)) || (bytesSent < 0 && WSAGetLastError() == WSAEWOULDBLOCK))
|
||||
#else
|
||||
@@ -1914,8 +1925,8 @@ void ILibAsyncSocket_PostSelect(void* socketModule, int slct, fd_set *readset, f
|
||||
module->PendingSend_Head->UserFree = ILibAsyncSocket_MemoryOwnership_CHAIN;
|
||||
module->PendingSend_Head->buffer = ILibMemory_Allocate((int)module->writeBioBuffer->length - bytesSent, 0, NULL, NULL);
|
||||
module->PendingSend_Head->bufferSize = (int)module->writeBioBuffer->length - bytesSent;
|
||||
module->PendingSend_Head->bytesSent = 0;
|
||||
memcpy_s(module->PendingSend_Head->buffer, module->PendingSend_Head->bufferSize, module->writeBioBuffer + bytesSent, module->PendingSend_Head->bufferSize);
|
||||
module->PendingSend_Head->bytesSent = 0;
|
||||
memcpy_s(module->PendingSend_Head->buffer, module->PendingSend_Head->bufferSize, module->writeBioBuffer->data + bytesSent, module->PendingSend_Head->bufferSize);
|
||||
|
||||
TLSLOG1(" <<-- BUFFERING[%d]: %d bytes -->>\n", module->internalSocket, module->PendingSend_Head->bufferSize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user