Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dvblast
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
dvblast
Commits
682a2bf2
Commit
682a2bf2
authored
Aug 26, 2011
by
Georgi Chorbadzhiyski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comm: Allow command answer to be split in multiple packets.
parent
a87ceb78
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
8 deletions
+41
-8
comm.c
comm.c
+21
-4
comm.h
comm.h
+4
-2
dvblastctl.c
dvblastctl.c
+16
-2
No files found.
comm.c
View file @
682a2bf2
...
...
@@ -41,7 +41,7 @@ int i_comm_fd = -1;
*****************************************************************************/
void
comm_Open
(
void
)
{
int
i_size
=
65535
;
int
i_size
=
COMM_MAX_MSG_CHUNK
;
struct
sockaddr_un
sun_server
;
if
(
(
i_comm_fd
=
socket
(
AF_UNIX
,
SOCK_DGRAM
,
0
))
==
-
1
)
...
...
@@ -164,10 +164,27 @@ void comm_Read( void )
p_answer
[
1
]
=
i_answer
;
p_answer
[
2
]
=
0
;
p_answer
[
3
]
=
0
;
uint32_t
*
p_size
=
(
uint32_t
*
)
&
p_answer
[
4
];
*
p_size
=
i_answer_size
+
COMM_HEADER_SIZE
;
msg_Dbg
(
NULL
,
"answering %d to %d with size %zd"
,
i_answer
,
i_command
,
i_answer_size
);
if
(
sendto
(
i_comm_fd
,
p_answer
,
i_answer_size
+
COMM_HEADER_SIZE
,
0
,
(
struct
sockaddr
*
)
&
sun_client
,
sun_length
)
<
0
)
msg_Err
(
NULL
,
"cannot send comm socket (%s)"
,
strerror
(
errno
)
);
#define min(a, b) (a < b ? a : b)
ssize_t
i_sended
=
0
;
ssize_t
i_to_send
=
i_answer_size
+
COMM_HEADER_SIZE
;
do
{
ssize_t
i_sent
=
sendto
(
i_comm_fd
,
p_answer
+
i_sended
,
min
(
i_to_send
,
COMM_MAX_MSG_CHUNK
),
0
,
(
struct
sockaddr
*
)
&
sun_client
,
sun_length
);
if
(
i_sent
<
0
)
{
msg_Err
(
NULL
,
"cannot send comm socket (%s)"
,
strerror
(
errno
)
);
break
;
}
i_sended
+=
i_sent
;
i_to_send
-=
i_sent
;
}
while
(
i_to_send
>
0
);
#undef min
}
comm.h
View file @
682a2bf2
...
...
@@ -19,10 +19,12 @@
#include <linux/dvb/frontend.h>
#include <linux/dvb/ca.h>
#define COMM_
BUFFER_SIZE 4096
#define COMM_
HEADER_SIZE 4
#define COMM_
HEADER_SIZE 8
#define COMM_
BUFFER_SIZE (COMM_HEADER_SIZE + ((PSI_PRIVATE_MAX_SIZE + PSI_HEADER_SIZE) * (PSI_TABLE_MAX_SECTIONS / 2)))
#define COMM_HEADER_MAGIC 0x48
#define COMM_MAX_MSG_CHUNK 65535
#define CMD_RELOAD 1
#define CMD_SHUTDOWN 2
#define CMD_FRONTEND_STATUS 3
...
...
dvblastctl.c
View file @
682a2bf2
...
...
@@ -59,7 +59,7 @@ int main( int i_argc, char **ppsz_argv )
char
*
client_socket_tmpl
=
"dvblastctl.clientsock.XXXXXX"
;
char
*
psz_srv_socket
=
NULL
;
int
i_fd
;
int
i
=
65535
;
int
i
=
COMM_MAX_MSG_CHUNK
;
ssize_t
i_size
;
struct
sockaddr_un
sun_client
,
sun_server
;
uint8_t
p_buffer
[
COMM_BUFFER_SIZE
];
...
...
@@ -239,7 +239,21 @@ int main( int i_argc, char **ppsz_argv )
exit
(
255
);
}
i_size
=
recv
(
i_fd
,
p_buffer
,
COMM_BUFFER_SIZE
,
0
);
uint32_t
i_packet_size
=
0
,
i_received
=
0
;
do
{
i_size
=
recv
(
i_fd
,
p_buffer
+
i_received
,
COMM_MAX_MSG_CHUNK
,
0
);
if
(
i_size
==
-
1
)
break
;
if
(
!
i_packet_size
)
{
i_packet_size
=
*
((
uint32_t
*
)
&
p_buffer
[
4
]);
if
(
i_packet_size
>
COMM_BUFFER_SIZE
)
{
i_size
=
-
1
;
break
;
}
}
i_received
+=
i_size
;
}
while
(
i_received
<
i_packet_size
);
close
(
i_fd
);
unlink
(
psz_client_socket
);
if
(
i_size
<
COMM_HEADER_SIZE
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment