Commit Graph

3 Commits

Author SHA1 Message Date
Kazuyoshi Kato
d240c5005f Use google.golang.org/protobuf instead of github.com/gogo/protobuf
This change replaces github.com/gogo/protobuf with
google.golang.org/protobuf, except for the code generators.

All proto-encoded structs are now generated from .proto files,
which include ttrpc.Request and ttrpc.Response.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-02-16 23:11:27 +00:00
Derek McGowan
f7a2e09ef8 Fix lint issues
Cleanup server test

Signed-off-by: Derek McGowan <derek@mcg.dev>
2022-01-21 12:04:30 -08:00
Wei Fu
225de2c936 client: add UserOnCloseWait function
ttrpc provides WithOnClose option for user and ttrpc will call the
callback function when connection is closed unexpectedly or the ttrpc
client's Close() method is called. containerd runtime plugin uses it
to handle cleanup the resources created by containerd shim.

But the ttrpc client's Close() is only trigger and the shim's cleanup
resource callback is called asynchronously, which might make part of
resources leaky. There is an example from containerd-runtime-v2 for
runc:

```happy
[Task.Delete goroutine]         [cleanupCallback goroutine]

call ttrpc client.Close() -->

                                  read bundle and call runc delete

delete bundle
```

If the cleanupCallback is called after deleting bundle, the callback
will fail to call runc delete. If there is any running processes, the
resource becomes leaky.

```unhappy
[Task.Delete goroutine]         [cleanupCallback goroutine]

call ttrpc client.Close() -->

delete bundle

                                  failed to read bundle and call runc delete
```

In order to avoid this, introduces the UserOnCloseWait to make sure that
the cleanupCallback has been called synchronously, like:

```
[Task.Delete goroutine]         [cleanupCallback goroutine]

call ttrpc client.Close() -->

wait for callback

                               read bundle and call runc delete

                          <--  finish sync

delete bundle
```

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2020-09-07 23:09:55 +08:00