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
This commit is contained in:
Rene Gollent 2010-02-28 21:58:29 +00:00
parent fb9a9911a8
commit 57dc77bb15
2 changed files with 27 additions and 16 deletions

View File

@ -27,7 +27,6 @@
#include <GradientConic.h>
#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);

View File

@ -14,11 +14,13 @@
#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
@ -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);