From 57dc77bb15d652788a9acbefd9b958352f861c91 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 28 Feb 2010 21:58:29 +0000 Subject: [PATCH] ServerLink tried to use the transfer_area semantics backwards ; this failed since only the owner of an area can transfer ownership elsewhere. As a result, sending messages which contained large enough amounts of data would fail entirely. This was most readily visible in Tracker, where some files (i.e. text/plain files where Tracker would attach the text content to the BMessage for DnD clipping purposes) would be undraggable due to the drag initiation message never getting successfully processed by app_server. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35679 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/LinkReceiver.cpp | 15 +-------------- src/kits/app/LinkSender.cpp | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/kits/app/LinkReceiver.cpp b/src/kits/app/LinkReceiver.cpp index 73095747ef..27d5219a5b 100644 --- a/src/kits/app/LinkReceiver.cpp +++ b/src/kits/app/LinkReceiver.cpp @@ -27,7 +27,6 @@ #include #include "link_message.h" -#include "syscalls.h" //#define DEBUG_BPORTLINK #ifdef DEBUG_BPORTLINK @@ -297,19 +296,7 @@ LinkReceiver::Read(void *data, ssize_t passedSize) fReadError = B_BAD_VALUE; if (fReadError >= B_OK) { - thread_info threadInfo; - get_thread_info(find_thread(NULL), &threadInfo); - - void* areaAddress = NULL; - if (areaInfo.team != threadInfo.team) { - sourceArea = _kern_transfer_area(sourceArea, &areaAddress, - B_ANY_ADDRESS, threadInfo.team); - - if (sourceArea < B_OK) - fReadError = sourceArea; - } else { - areaAddress = areaInfo.address; - } + void* areaAddress = areaInfo.address; if (areaAddress && sourceArea >= B_OK) { memcpy(data, areaAddress, passedSize); diff --git a/src/kits/app/LinkSender.cpp b/src/kits/app/LinkSender.cpp index 1f2b3d714c..182d840f84 100644 --- a/src/kits/app/LinkSender.cpp +++ b/src/kits/app/LinkSender.cpp @@ -14,11 +14,13 @@ #include #include +#include +#include #include #include #include "link_message.h" - +#include "syscalls.h" //#define DEBUG_BPORTLINK #ifdef DEBUG_BPORTLINK @@ -161,6 +163,19 @@ LinkSender::Attach(const void *passedData, size_t passedSize) area_id senderArea = -1; if (useArea) { + team_id target = -1; + port_id port = -1; + if (be_app == NULL) + port = fPort; + else + port = get_app_server_port(); + + port_info info; + status_t result = get_port_info(port, &info); + if (result != B_OK) + return result; + + target = info.team; void* address = NULL; off_t alignedSize = (passedSize + B_PAGE_SIZE) & ~(B_PAGE_SIZE - 1); senderArea = create_area("LinkSenderArea", &address, B_ANY_ADDRESS, @@ -168,9 +183,18 @@ LinkSender::Attach(const void *passedData, size_t passedSize) if (senderArea < B_OK) return senderArea; - + data = &senderArea; memcpy(address, passedData, passedSize); + + area_id areaID = senderArea; + senderArea = _kern_transfer_area(senderArea, &address, + B_ANY_ADDRESS, target); + + if (senderArea < B_OK) { + delete_area(areaID); + return senderArea; + } } memcpy(fBuffer + fCurrentEnd, data, size);