Code Review
/
src
/
drm-lease-manager.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Add support for lease transition
[src/drm-lease-manager.git]
/
drm-lease-manager
/
main.c
diff --git
a/drm-lease-manager/main.c
b/drm-lease-manager/main.c
index
491c80c
..
78ff0df
100644
(file)
--- a/
drm-lease-manager/main.c
+++ b/
drm-lease-manager/main.c
@@
-27,14
+27,16
@@
static void usage(const char *progname)
printf("Usage: %s [OPTIONS] [<DRM device>]\n\n"
"Options:\n"
"-h, --help \tPrint this help\n"
printf("Usage: %s [OPTIONS] [<DRM device>]\n\n"
"Options:\n"
"-h, --help \tPrint this help\n"
- "-v, --verbose \tEnable verbose debug messages\n",
+ "-v, --verbose \tEnable verbose debug messages\n"
+ "-t, --lease-transfer \tAllow lease transfter to new clients\n",
progname);
}
progname);
}
-const char *opts = "vh";
+const char *opts = "v
t
h";
const struct option options[] = {
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
const struct option options[] = {
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
+ {"lease-transfer", no_argument, NULL, 't'},
{NULL, 0, NULL, 0},
};
{NULL, 0, NULL, 0},
};
@@
-43,6
+45,7
@@
int main(int argc, char **argv)
char *device = "/dev/dri/card0";
bool debug_log = false;
char *device = "/dev/dri/card0";
bool debug_log = false;
+ bool can_transfer_leases = false;
int c;
while ((c = getopt_long(argc, argv, opts, options, NULL)) != -1) {
int c;
while ((c = getopt_long(argc, argv, opts, options, NULL)) != -1) {
@@
-51,6
+54,9
@@
int main(int argc, char **argv)
case 'v':
debug_log = true;
break;
case 'v':
debug_log = true;
break;
+ case 't':
+ can_transfer_leases = true;
+ break;
case 'h':
ret = EXIT_SUCCESS;
/* fall through */
case 'h':
ret = EXIT_SUCCESS;
/* fall through */
@@
-87,6
+93,10
@@
int main(int argc, char **argv)
switch (req.type) {
case LS_REQ_GET_LEASE: {
int fd = lm_lease_grant(lm, req.lease_handle);
switch (req.type) {
case LS_REQ_GET_LEASE: {
int fd = lm_lease_grant(lm, req.lease_handle);
+
+ if (fd < 0 && can_transfer_leases)
+ fd = lm_lease_transfer(lm, req.lease_handle);
+
if (fd < 0) {
ERROR_LOG(
"Can't fulfill lease request: lease=%s\n",
if (fd < 0) {
ERROR_LOG(
"Can't fulfill lease request: lease=%s\n",
@@
-95,6
+105,13
@@
int main(int argc, char **argv)
break;
}
break;
}
+ struct ls_client *active_client =
+ req.lease_handle->user_data;
+ if (active_client)
+ ls_disconnect_client(ls, active_client);
+
+ req.lease_handle->user_data = req.client;
+
if (!ls_send_fd(ls, req.client, fd)) {
ERROR_LOG(
"Client communication error: lease=%s\n",
if (!ls_send_fd(ls, req.client, fd)) {
ERROR_LOG(
"Client communication error: lease=%s\n",
@@
-106,6
+123,7
@@
int main(int argc, char **argv)
}
case LS_REQ_RELEASE_LEASE:
ls_disconnect_client(ls, req.client);
}
case LS_REQ_RELEASE_LEASE:
ls_disconnect_client(ls, req.client);
+ req.lease_handle->user_data = NULL;
lm_lease_revoke(lm, req.lease_handle);
break;
default:
lm_lease_revoke(lm, req.lease_handle);
break;
default: