Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
core
tarantool
Commits
982801e1
Commit
982801e1
authored
12 years ago
by
Konstantin Osipov
Browse files
Options
Downloads
Plain Diff
Merge branch 'stable'
parents
bd76ca4e
152e3e00
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/iobuf.h
+16
-16
16 additions, 16 deletions
include/iobuf.h
src/iobuf.m
+5
-3
5 additions, 3 deletions
src/iobuf.m
src/iproto.m
+9
-3
9 additions, 3 deletions
src/iproto.m
with
30 additions
and
22 deletions
include/iobuf.h
+
16
−
16
View file @
982801e1
...
...
@@ -136,39 +136,39 @@ obuf_iovcnt(struct obuf *buf)
return
buf
->
iov
[
buf
->
pos
].
iov_len
>
0
?
buf
->
pos
+
1
:
buf
->
pos
;
}
/**
* Output buffer savepoint. It's possible to
* save the current buffer state in a savepoint
* and roll back to the saved state at any time
* before iobuf_flush()
*/
struct
obuf_svp
{
size_t
pos
;
size_t
iov_len
;
size_t
size
;
};
/**
* Reserve size bytes in the output buffer
* and return a pointer to the reserved
* data. Returns a pointer to a continuous piece of
* memory.
* Typical use case:
*
void *psize
= obuf_book(buf, sizeof(uint32_t));
*
struct obuf_svp svp
= obuf_book(buf, sizeof(uint32_t));
* for (...)
* obuf_dup(buf, ...);
* uint32_t total = obuf_size(buf);
* memcpy(
psize
, &total, sizeof(total);
* memcpy(
obuf_svp_to_ptr(&svp)
, &total, sizeof(total);
* iobuf_flush();
*/
void
*
struct
obuf_svp
obuf_book
(
struct
obuf
*
obuf
,
size_t
size
);
/** Append data to the output buffer. */
void
obuf_dup
(
struct
obuf
*
obuf
,
const
void
*
data
,
size_t
size
);
/**
* Output buffer savepoint. It's possible to
* save the current buffer state in a savepoint
* and roll back to the saved state at any time
* before iobuf_flush()
*/
struct
obuf_svp
{
size_t
pos
;
size_t
iov_len
;
size_t
size
;
};
static
inline
struct
obuf_svp
obuf_create_svp
(
struct
obuf
*
buf
)
{
...
...
This diff is collapsed.
Click to expand it.
src/iobuf.m
+
5
−
3
View file @
982801e1
...
...
@@ -200,7 +200,7 @@ obuf_dup(struct obuf *buf, const void *data, size_t size)
}
/** Book a few bytes in the output buffer. */
void *
struct obuf_svp
obuf_book(struct obuf *buf, size_t size)
{
struct iovec *iov =
&buf->iov[buf->pos];
...
...
@@ -221,11 +221,13 @@ obuf_book(struct obuf *buf, size_t size)
obuf_alloc_pos(buf, buf->pos, size);
}
}
void *booking = iov->iov_base + iov->iov_len;
struct obuf_svp svp = {
.pos = buf->pos, .iov_len = iov->iov_len, .size = buf->size
};
iov->iov_len += size;
buf->size += size;
assert(iov->iov_len
<
=
buf-
>
capacity[buf->pos]);
return
booking
;
return
svp
;
}
/** Forget about data in the output buffer beyond the savepoint. */
...
...
This diff is collapsed.
Click to expand it.
src/iproto.m
+
9
−
3
View file @
982801e1
...
...
@@ -138,8 +138,7 @@ port_iproto_add_tuple(struct port *ptr, struct tuple *tuple, u32 flags)
struct
port
_
iproto
*
port
=
port
_
iproto
(
ptr
)
;
if
(
++
port
->
reply
.
found
==
1
)
{
/*
Found
the
first
tuple
,
add
header
.
*/
port
->
svp
=
obuf
_
create
_
svp
(
port
->
buf
)
;
obuf
_
book
(
port
->
buf
,
sizeof
(
port
->
reply
))
;
port
->
svp
=
obuf
_
book
(
port
->
buf
,
sizeof
(
port
->
reply
))
;
}
if
(
flags
&
BOX
_
RETURN
_
TUPLE
)
{
obuf
_
dup
(
port
->
buf
,
&
tuple
->
bsize
,
tuple
_
len
(
tuple
))
;
...
...
@@ -635,7 +634,14 @@ iproto_session_output_iobuf(struct iproto_session *session)
{
if (obuf_size(&session->iobuf[1]->out))
return session->iobuf[1];
if (obuf_size(&session->iobuf[0]->out))
/*
* Don't try to write from a newer buffer if an older one
* exists: in case of a partial write of a newer buffer,
* the client may end up getting a salad of different
* pieces of replies from both buffers.
*/
if (ibuf_size(&session->iobuf[1]->in) == 0 &&
obuf_size(&session->iobuf[0]->out))
return session->iobuf[0];
return NULL;
}
...
...
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