Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
b00bef2f
Commit
b00bef2f
authored
10 years ago
by
Henrik (Grubba) Grubbström
Browse files
Options
Downloads
Patches
Plain Diff
SSL.File: More clean-ups in write().
Reduces the code complexity in write() a bit further.
parent
e3d3555b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/SSL.pmod/File.pike
+38
-35
38 additions, 35 deletions
lib/modules/SSL.pmod/File.pike
with
38 additions
and
35 deletions
lib/modules/SSL.pmod/File.pike
+
38
−
35
View file @
b00bef2f
...
...
@@ -966,49 +966,52 @@ int write (string|array(string) data, mixed... args)
// Take care of any old data first.
if (!direct_write()) RETURN (-1);
int written = 0;
int idx = 0, pos = 0;
while (idx < sizeof (data) && !sizeof (write_buffer) &&
int write_limit = 0x7fffffff;
if (nonblocking_mode) {
// Always stop after writing DATA_CHUNK_SIZE in
// nonblocking mode, so that we don't loop here
// arbitrarily long if the write is very large and the
// bottleneck is in the encryption.
(!nonblocking_mode || written < Stdio.DATA_CHUNK_SIZE)) {
int size = sizeof (data[idx]) - pos;
if (size > fragment_max_size) {
write_limit = Stdio.DATA_CHUNK_SIZE;
}
int written = 0;
int idx = 0, pos = 0;
while (idx < sizeof (data) && !sizeof (write_buffer) &&
written < write_limit) {
#ifdef SSL3_DEBUG
int oidx = idx;
int opos = pos;
#endif
// send_streaming_data will pick the first fragment_max_size
// bytes of the string, so do that right away in the same
// range operation.
int n = conn->send_streaming_data (
data[idx][pos..pos + fragment_max_size - 1]);
SSL3_DEBUG_MSG ("SSL.File->write: Queued data[%d][%d..%d]\n",
idx, pos, pos + n - 1);
written += n;
pos += n;
}
string frag = data[idx][pos..pos + fragment_max_size -1];
pos += fragment_max_size;
else
{
while (sizeof(frag) < fragment_max_size)
{
// Try to fill a packet.
int end;
for (end = idx + 1; end < sizeof (data); end++) {
int newsize = size + sizeof (data[end]);
if (newsize > fragment_max_size) break;
size = newsize;
if (++idx >= sizeof(data)) break;
pos = fragment_max_size - sizeof(frag);
frag += data[idx][..pos -1];
}
if (
conn->send_streaming_data (
`+ (data[idx][pos..], @data[idx+1..end-1])) < size)
int n =
conn->send_streaming_data (
frag);
if (n != sizeof(frag)) {
error ("Unexpected fragment_max_size discrepancy wrt send_streaming_data.\n");
SSL3_DEBUG_MSG ("SSL.File->write: "
"Queued data[%d][%d..%d] + data[%d..%d]\n",
idx, pos, sizeof (data[idx]) - 1, idx + 1, end - 1);
written += size;
idx = end;
pos = 0;
}
#ifdef SSL3_DEBUG
if (oidx == idx) {
SSL3_DEBUG_MSG("SSL.File->write: Queued data[%d][%d..%d]\n",
idx, opos, pos - 1);
} else {
SSL3_DEBUG_MSG("SSL.File->write: Queued data[%d..%d][%d..%d]\n",
oidx, idx, opos, pos - 1);
}
#endif
written += n;
if (!direct_write()) RETURN (written);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment