Author: anevilyak Date: 2010-02-28 22:58:29 +0100 (Sun, 28 Feb 2010) New Revision: 35679 Changeset: http://dev.haiku-os.org/changeset/35679/haiku Modified: haiku/trunk/src/kits/app/LinkReceiver.cpp haiku/trunk/src/kits/app/LinkSender.cpp Log: 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. Modified: haiku/trunk/src/kits/app/LinkReceiver.cpp =================================================================== --- haiku/trunk/src/kits/app/LinkReceiver.cpp 2010-02-28 21:50:34 UTC (rev 35678) +++ haiku/trunk/src/kits/app/LinkReceiver.cpp 2010-02-28 21:58:29 UTC (rev 35679) @@ -27,7 +27,6 @@ #include <GradientConic.h> #include "link_message.h" -#include "syscalls.h" //#define DEBUG_BPORTLINK #ifdef DEBUG_BPORTLINK @@ -297,19 +296,7 @@ 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); Modified: haiku/trunk/src/kits/app/LinkSender.cpp =================================================================== --- haiku/trunk/src/kits/app/LinkSender.cpp 2010-02-28 21:50:34 UTC (rev 35678) +++ haiku/trunk/src/kits/app/LinkSender.cpp 2010-02-28 21:58:29 UTC (rev 35679) @@ -14,12 +14,14 @@ #include <string.h> #include <new> +#include <Application.h> +#include <AppMisc.h> #include <ServerProtocol.h> #include <LinkSender.h> #include "link_message.h" +#include "syscalls.h" - //#define DEBUG_BPORTLINK #ifdef DEBUG_BPORTLINK # include <stdio.h> @@ -161,6 +163,19 @@ 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 @@ 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);