Bluetooth: Fix L2capEndpoint::SendData() returning no of bytes sent
instead of status Change-Id: Ic3668dec8f443853286d1c098a237c85a54a7ae4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/11201 Reviewed-by: waddlesplash <[email protected]> Haiku-Format: Haiku-format Bot <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
94deadca17
commit
2cbf45bc81
@@ -398,7 +398,7 @@ L2capEndpoint::ReadData(size_t numBytes, uint32 flags, net_buffer** _buffer)
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
status_t
|
||||
L2capEndpoint::SendData(net_buffer* buffer)
|
||||
{
|
||||
CALLED();
|
||||
@@ -410,36 +410,17 @@ L2capEndpoint::SendData(net_buffer* buffer)
|
||||
if (fState != OPEN)
|
||||
return ENOTCONN;
|
||||
|
||||
ssize_t sent = 0;
|
||||
while (buffer != NULL) {
|
||||
net_buffer* current = buffer;
|
||||
buffer = NULL;
|
||||
if (current->size > fChannelConfig.outgoing_mtu) {
|
||||
// Break up into MTU-sized chunks.
|
||||
buffer = gBufferModule->split(current, fChannelConfig.outgoing_mtu);
|
||||
if (buffer == NULL) {
|
||||
if (sent > 0) {
|
||||
gBufferModule->free(current);
|
||||
return sent;
|
||||
}
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
if (buffer->size > fChannelConfig.outgoing_mtu)
|
||||
return EMSGSIZE;
|
||||
|
||||
const size_t bufferSize = current->size;
|
||||
status_t status = gStackModule->fifo_enqueue_buffer(&fSendQueue, current);
|
||||
if (status != B_OK) {
|
||||
gBufferModule->free(current);
|
||||
return sent;
|
||||
}
|
||||
|
||||
sent += bufferSize;
|
||||
}
|
||||
status_t status = gStackModule->fifo_enqueue_buffer(&fSendQueue, buffer);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
if (!gStackModule->is_timer_active(&fSendTimer))
|
||||
gStackModule->set_timer(&fSendTimer, 0);
|
||||
|
||||
return sent;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
uint16 ChannelID() const { return fChannelID; }
|
||||
|
||||
ssize_t ReadData(size_t numBytes, uint32 flags, net_buffer** _buffer);
|
||||
ssize_t SendData(net_buffer* buffer);
|
||||
status_t SendData(net_buffer* buffer);
|
||||
status_t ReceiveData(net_buffer* buffer);
|
||||
ssize_t Sendable();
|
||||
ssize_t Receivable();
|
||||
|
||||
Reference in New Issue
Block a user