Remove the small allocations
This is not compatible with multithreading and would require a complete re-design. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
28
lib/pdu.c
28
lib/pdu.c
@@ -187,7 +187,7 @@ void iscsi_dump_pdu_header(struct iscsi_context *iscsi, unsigned char *data) {
|
||||
struct iscsi_pdu*
|
||||
iscsi_tcp_new_pdu(struct iscsi_context *iscsi, size_t size)
|
||||
{
|
||||
return iscsi_szmalloc(iscsi, size);
|
||||
return iscsi_zmalloc(iscsi, size);
|
||||
}
|
||||
|
||||
struct iscsi_pdu *
|
||||
@@ -204,7 +204,7 @@ iscsi_allocate_pdu(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
|
||||
}
|
||||
|
||||
pdu->outdata.size = ISCSI_HEADER_SIZE(iscsi->header_digest);
|
||||
pdu->outdata.data = iscsi_szmalloc(iscsi, pdu->outdata.size);
|
||||
pdu->outdata.data = iscsi_zmalloc(iscsi, pdu->outdata.size);
|
||||
|
||||
if (pdu->outdata.data == NULL) {
|
||||
iscsi_set_error(iscsi, "failed to allocate pdu header");
|
||||
@@ -242,25 +242,17 @@ iscsi_tcp_free_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
|
||||
return;
|
||||
}
|
||||
|
||||
if (pdu->outdata.size <= iscsi->smalloc_size) {
|
||||
iscsi_sfree(iscsi, pdu->outdata.data);
|
||||
} else {
|
||||
iscsi_free(iscsi, pdu->outdata.data);
|
||||
}
|
||||
iscsi_free(iscsi, pdu->outdata.data);
|
||||
pdu->outdata.data = NULL;
|
||||
|
||||
if (pdu->indata.size <= iscsi->smalloc_size) {
|
||||
iscsi_sfree(iscsi, pdu->indata.data);
|
||||
} else {
|
||||
iscsi_free(iscsi, pdu->indata.data);
|
||||
}
|
||||
iscsi_free(iscsi, pdu->indata.data);
|
||||
pdu->indata.data = NULL;
|
||||
|
||||
if (iscsi->outqueue_current == pdu) {
|
||||
iscsi->outqueue_current = NULL;
|
||||
}
|
||||
|
||||
iscsi_sfree(iscsi, pdu);
|
||||
iscsi_free(iscsi, pdu);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -283,15 +275,9 @@ iscsi_add_data(struct iscsi_context *iscsi, struct iscsi_data *data,
|
||||
}
|
||||
|
||||
if (data->size == 0) {
|
||||
if (aligned <= iscsi->smalloc_size) {
|
||||
data->data = iscsi_szmalloc(iscsi, aligned);
|
||||
} else {
|
||||
data->data = iscsi_malloc(iscsi, aligned);
|
||||
}
|
||||
data->data = iscsi_malloc(iscsi, aligned);
|
||||
} else {
|
||||
if (aligned > iscsi->smalloc_size) {
|
||||
data->data = iscsi_realloc(iscsi, data->data, aligned);
|
||||
}
|
||||
data->data = iscsi_realloc(iscsi, data->data, aligned);
|
||||
}
|
||||
if (data->data == NULL) {
|
||||
iscsi_set_error(iscsi, "failed to allocate buffer for %d "
|
||||
|
||||
Reference in New Issue
Block a user