* Just use the heap instead of cbuf for send_data().

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33722 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-10-22 11:42:51 +00:00
parent 4bee71c211
commit 68d9d8809b
2 changed files with 14 additions and 16 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2008, Haiku Inc. * Copyright 2004-2009, Haiku Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Thread definition and structures * Thread definition and structures
@@ -7,9 +7,9 @@
#ifndef _KERNEL_THREAD_TYPES_H #ifndef _KERNEL_THREAD_TYPES_H
#define _KERNEL_THREAD_TYPES_H #define _KERNEL_THREAD_TYPES_H
#ifndef _ASSEMBLER #ifndef _ASSEMBLER
#include <cbuf.h>
#include <smp.h> #include <smp.h>
#include <signal.h> #include <signal.h>
#include <thread_defs.h> #include <thread_defs.h>
@@ -274,7 +274,7 @@ struct thread {
thread_id sender; thread_id sender;
int32 code; int32 code;
size_t size; size_t size;
cbuf *buffer; void* buffer;
} msg; } msg;
union { union {
+11 -13
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008, Axel Dörfler, [email protected]. * Copyright 2002-2009, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -698,7 +698,6 @@ send_data_etc(thread_id id, int32 code, const void *buffer, size_t bufferSize,
sem_id cachedSem; sem_id cachedSem;
cpu_status state; cpu_status state;
status_t status; status_t status;
cbuf *data;
state = disable_interrupts(); state = disable_interrupts();
GRAB_THREAD_LOCK(); GRAB_THREAD_LOCK();
@@ -725,14 +724,14 @@ send_data_etc(thread_id id, int32 code, const void *buffer, size_t bufferSize,
return B_BAD_THREAD_ID; return B_BAD_THREAD_ID;
} }
void* data;
if (bufferSize > 0) { if (bufferSize > 0) {
data = cbuf_get_chain(bufferSize); data = malloc(bufferSize);
if (data == NULL) if (data == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
status = cbuf_user_memcpy_to_chain(data, 0, buffer, bufferSize); if (user_memcpy(data, buffer, bufferSize) != B_OK) {
if (status < B_OK) { free(data);
cbuf_free_chain(data); return B_BAD_DATA;
return B_NO_MEMORY;
} }
} else } else
data = NULL; data = NULL;
@@ -745,7 +744,7 @@ send_data_etc(thread_id id, int32 code, const void *buffer, size_t bufferSize,
if (target == NULL) { if (target == NULL) {
RELEASE_THREAD_LOCK(); RELEASE_THREAD_LOCK();
restore_interrupts(state); restore_interrupts(state);
cbuf_free_chain(data); free(data);
return B_BAD_THREAD_ID; return B_BAD_THREAD_ID;
} }
@@ -784,10 +783,9 @@ receive_data_etc(thread_id *_sender, void *buffer, size_t bufferSize,
if (buffer != NULL && bufferSize != 0 && thread->msg.buffer != NULL) { if (buffer != NULL && bufferSize != 0 && thread->msg.buffer != NULL) {
size = min_c(bufferSize, thread->msg.size); size = min_c(bufferSize, thread->msg.size);
status = cbuf_user_memcpy_from_chain(buffer, thread->msg.buffer, status = user_memcpy(buffer, thread->msg.buffer, size);
0, size); if (status != B_OK) {
if (status < B_OK) { free(thread->msg.buffer);
cbuf_free_chain(thread->msg.buffer);
release_sem(thread->msg.write_sem); release_sem(thread->msg.write_sem);
return status; return status;
} }
@@ -796,7 +794,7 @@ receive_data_etc(thread_id *_sender, void *buffer, size_t bufferSize,
*_sender = thread->msg.sender; *_sender = thread->msg.sender;
code = thread->msg.code; code = thread->msg.code;
cbuf_free_chain(thread->msg.buffer); free(thread->msg.buffer);
release_sem(thread->msg.write_sem); release_sem(thread->msg.write_sem);
return code; return code;