Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
lektor
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
5669af5c
Vérifiée
Valider
5669af5c
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Adding functions to alter continuation state of a client.
parent
7eccb2b7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!56
Search
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
inc/lektor/net.h
+4
-0
4 ajouts, 0 suppression
inc/lektor/net.h
src/net/listen.c
+30
-4
30 ajouts, 4 suppressions
src/net/listen.c
avec
34 ajouts
et
4 suppressions
inc/lektor/net.h
+
4
−
0
Voir le fichier @
5669af5c
...
@@ -46,6 +46,10 @@ struct lkt_state {
...
@@ -46,6 +46,10 @@ struct lkt_state {
/* Send a message to the connected client. */
/* Send a message to the connected client. */
void
lkt_state_send
(
struct
lkt_state
*
srv
,
size_t
c
,
struct
lkt_message
*
msg
);
void
lkt_state_send
(
struct
lkt_state
*
srv
,
size_t
c
,
struct
lkt_message
*
msg
);
/* Get and set continuation state for a client. */
bool
lkt_get_continuation
(
struct
lkt_state
*
srv
,
size_t
c
);
void
lkt_set_continuation
(
struct
lkt_state
*
srv
,
size_t
c
,
int
i
);
/* Get the mask to watch for events for a given client, to be used with the `idle` command.
/* Get the mask to watch for events for a given client, to be used with the `idle` command.
* Return a pointer to the client's mask */
* Return a pointer to the client's mask */
enum
mpd_idle_flag
*
lkt_client_get_mask
(
struct
lkt_state
*
srv
,
size_t
c
);
enum
mpd_idle_flag
*
lkt_client_get_mask
(
struct
lkt_state
*
srv
,
size_t
c
);
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/net/listen.c
+
30
−
4
Voir le fichier @
5669af5c
...
@@ -54,13 +54,25 @@ struct lkt_client {
...
@@ -54,13 +54,25 @@ struct lkt_client {
bool
request_close
;
bool
request_close
;
bool
authentificated
;
bool
authentificated
;
int
continuation
;
};
};
static
bool
static
inline
bool
lkt_close_client
(
struct
lkt_state
*
srv
,
size_t
c
)
lkt_close_client
(
struct
lkt_state
*
srv
,
size_t
c
)
{
{
srv
->
clients
[
c
-
1
].
request_close
=
true
;
return
srv
->
clients
[
c
-
1
].
request_close
=
true
;
return
true
;
}
inline
bool
lkt_get_continuation
(
struct
lkt_state
*
srv
,
size_t
c
)
{
return
srv
->
clients
[
c
-
1
].
continuation
;
}
inline
void
lkt_set_continuation
(
struct
lkt_state
*
srv
,
size_t
c
,
int
i
)
{
srv
->
clients
[
c
-
1
].
continuation
=
i
;
}
}
void
void
...
@@ -77,6 +89,15 @@ lkt_state_send(struct lkt_state *srv, size_t c, struct lkt_message *msg)
...
@@ -77,6 +89,15 @@ lkt_state_send(struct lkt_state *srv, size_t c, struct lkt_message *msg)
srv
->
fds
[
c
].
events
|=
POLLOUT
;
srv
->
fds
[
c
].
events
|=
POLLOUT
;
}
}
static
inline
void
send_continue
(
struct
lkt_state
*
srv
,
size_t
c
,
int
i
)
{
struct
lkt_message
*
cont
=
lkt_message_new
();
cont
->
data_len
=
snprintf
(
cont
->
data
,
LKT_MESSAGE_MAX
,
"continue: %d
\n
"
,
i
);
cont
->
data
[
LKT_MESSAGE_MAX
-
1
]
=
'\0'
;
lkt_state_send
(
srv
,
c
,
cont
);
}
static
void
static
void
send_ok
(
struct
lkt_state
*
srv
,
size_t
c
)
send_ok
(
struct
lkt_state
*
srv
,
size_t
c
)
{
{
...
@@ -137,7 +158,8 @@ handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd)
...
@@ -137,7 +158,8 @@ handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd)
switch
(
*
lkt_client_get_mask
(
srv
,
c
))
{
switch
(
*
lkt_client_get_mask
(
srv
,
c
))
{
case
MPD_IDLE_NONE
:
case
MPD_IDLE_NONE
:
/* Commands that require authentification. */
/* Commands that require authentification.
TODO: Move authentification verification inside commands. */
if
(
lkt_client_auth
(
srv
,
c
,
false
))
{
if
(
lkt_client_auth
(
srv
,
c
,
false
))
{
if
(
!
strcmp
(
cmd
.
name
,
"__adduser"
))
{
if
(
!
strcmp
(
cmd
.
name
,
"__adduser"
))
{
err
=
!
command_user_add
(
srv
->
db
,
cmd
.
args
);
err
=
!
command_user_add
(
srv
->
db
,
cmd
.
args
);
...
@@ -164,6 +186,10 @@ handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd)
...
@@ -164,6 +186,10 @@ handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd)
err
=
!
lkt_close_client
(
srv
,
c
);
err
=
!
lkt_close_client
(
srv
,
c
);
else
if
(
!
strcmp
(
cmd
.
name
,
"ping"
))
else
if
(
!
strcmp
(
cmd
.
name
,
"ping"
))
err
=
0
;
err
=
0
;
else
if
(
!
strcmp
(
cmd
.
name
,
"continue"
))
{
srv
->
clients
[
c
-
1
].
continuation
=
atoi
(
cmd
.
args
[
0
]);
err
=
0
;
}
else
if
(
!
strcmp
(
cmd
.
name
,
"next"
))
else
if
(
!
strcmp
(
cmd
.
name
,
"next"
))
err
=
!
command_next
(
srv
->
db
,
&
srv
->
win
,
&
srv
->
mpd_idle_events
);
err
=
!
command_next
(
srv
->
db
,
&
srv
->
win
,
&
srv
->
mpd_idle_events
);
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter