Skip to content

Commit

Permalink
Merge pull request #161 from jairinhohw/master
Browse files Browse the repository at this point in the history
Fixed blobs greater than 65535 bytes
  • Loading branch information
fernandobatels authored Nov 27, 2024
2 parents 5c094a2 + 83a612e commit 215f5c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
21 changes: 12 additions & 9 deletions rsfbclient-native/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,18 @@ fn binary_to_blob<T: IBase>(
// Assert that the handle is valid
debug_assert_ne!(handle, 0);

unsafe {
if ibase.isc_put_segment()(
&mut status[0],
&mut handle,
bytes.len() as u16,
bytes.as_ptr() as *mut std::os::raw::c_char,
) != 0
{
return Err(status.as_error(ibase));
// Max segment size: 65535
for b in bytes.chunks(65535) {
unsafe {
if ibase.isc_put_segment()(
&mut status[0],
&mut handle,
b.len() as u16,
b.as_ptr() as *mut std::os::raw::c_char,
) != 0
{
return Err(status.as_error(ibase));
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/tests/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ mk_tests_default! {

let rstr: Vec<u8> = rand::thread_rng()
.sample_iter::<u8, _>(Standard)
.take(10000)
.take(1024 * 1024)
.collect();

conn.execute("DROP TABLE PBIGBLOBBIN", ()).ok();
Expand All @@ -261,7 +261,7 @@ mk_tests_default! {

let rstr: String = rand::thread_rng()
.sample_iter::<char, _>(Standard)
.take(10000)
.take(1024 * 1024)
.collect();

conn.execute("DROP TABLE PBIGBLOBTEXT", ()).ok();
Expand Down
4 changes: 2 additions & 2 deletions src/tests/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ mk_tests_default! {

let rvec: Vec<u8> = rand::thread_rng()
.sample_iter(Standard)
.take(10000)
.take(1024 * 1024)
.collect();

conn.execute("DROP TABLE RBIGBLOBBIN", ()).ok();
Expand All @@ -187,7 +187,7 @@ mk_tests_default! {

let rstr: String = rand::thread_rng()
.sample_iter::<char, _>(Standard)
.take(10000)
.take(1024 * 1024)
.collect();

conn.execute("DROP TABLE RBIGBLOBTEXT", ()).ok();
Expand Down

0 comments on commit 215f5c0

Please sign in to comment.