o Improve error handling when processing files
o Add OPTIONS SO_KEEPALIVE and TCP_NODELAY o Uphold hier(7) and install ccxstream under sbin/ instead of bin/ o Bump PORTREVISION
This commit is contained in:
parent
d573189a41
commit
3093438e1d
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=191897
4 changed files with 99 additions and 16 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
PORTNAME= ccxstream
|
||||
PORTVERSION= 1.0.15
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= net
|
||||
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
|
||||
MASTER_SITE_SUBDIR= xbplayer
|
||||
|
@ -14,28 +15,25 @@ MASTER_SITE_SUBDIR= xbplayer
|
|||
MAINTAINER= ports@FreeBSD.org
|
||||
COMMENT= Stream media files to XBox Media Center via XBMSP
|
||||
|
||||
OPTIONS= SO_KEEPALIVE "Build with SO_KEEPALIVE" ON \
|
||||
TCP_NODELAY "Build with TCP_NODELAY" OFF
|
||||
|
||||
USE_GMAKE= yes
|
||||
MAKE_ENV= CC="${CC}"
|
||||
USE_RC_SUBR= ccxstream
|
||||
|
||||
USE_RC_SUBR= yes
|
||||
RC_SCRIPTS_SUB= PREFIX=${PREFIX} RC_SUBR=${RC_SUBR}
|
||||
SAMPLERC= ${PORTNAME}.sh.sample
|
||||
REALRC= ${SAMPLERC:S/.sample//}
|
||||
|
||||
PLIST_FILES= bin/ccxstream bin/ccxtest etc/rc.d/${REALRC}
|
||||
PLIST_FILES= \
|
||||
bin/ccxtest \
|
||||
sbin/ccxstream
|
||||
|
||||
.if !defined(NOPORTDOCS)
|
||||
PORTDOCS= README ChangeLog TODO xbmsp-xml.txt xbmsp.txt
|
||||
.endif
|
||||
|
||||
post-build:
|
||||
@${SED} ${RC_SCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
|
||||
${FILESDIR}/${SAMPLERC} > ${WRKDIR}/${SAMPLERC}
|
||||
|
||||
do-install:
|
||||
@${MKDIR} ${PREFIX}/bin
|
||||
@${INSTALL_PROGRAM} ${WRKSRC}/ccxstream ${PREFIX}/bin
|
||||
@${MKDIR} ${PREFIX}/sbin
|
||||
@${INSTALL_PROGRAM} ${WRKSRC}/ccxstream ${PREFIX}/sbin
|
||||
@${INSTALL_PROGRAM} ${WRKSRC}/ccxtest ${PREFIX}/bin
|
||||
@${INSTALL_SCRIPT} ${WRKDIR}/${SAMPLERC} ${PREFIX}/etc/rc.d/${REALRC}
|
||||
.if !defined(NOPORTDOCS)
|
||||
@${MKDIR} ${DOCSDIR}
|
||||
.for i in ${PORTDOCS}
|
||||
|
@ -44,6 +42,18 @@ do-install:
|
|||
.endif
|
||||
|
||||
post-install:
|
||||
@${CAT} pkg-message
|
||||
@${CAT} ${PKGMESSAGE}
|
||||
|
||||
.include <bsd.port.mk>
|
||||
.include <bsd.port.pre.mk>
|
||||
|
||||
# enable SO_KEEPALIVE
|
||||
.if defined(WITH_SO_KEEPALIVE)
|
||||
CFLAGS+= -DSO_KEEPALIVE
|
||||
.endif
|
||||
|
||||
# enable TCP_NODELAY
|
||||
.if defined(WITH_TCP_NODELAY)
|
||||
CFLAGS+= -DTCP_NODELAY
|
||||
.endif
|
||||
|
||||
.include <bsd.port.post.mk>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
name="ccxstream"
|
||||
rcvar=`set_rcvar`
|
||||
|
||||
command="%%PREFIX%%/bin/ccxstream"
|
||||
command="%%PREFIX%%/sbin/ccxstream"
|
||||
|
||||
load_rc_config "$name"
|
||||
: ${ccxstream_enable="NO"}
|
14
net/ccxstream/files/patch-ccxclientconn.c
Normal file
14
net/ccxstream/files/patch-ccxclientconn.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
--- ccxclientconn.c.orig Mon Mar 17 11:29:15 2003
|
||||
+++ ccxclientconn.c Tue May 15 14:58:52 2007
|
||||
@@ -51,6 +51,11 @@
|
||||
i = 1;
|
||||
setsockopt(sock, IPPROTO_TCP,TCP_NODELAY, &i, sizeof (i));
|
||||
#endif /* TCP_NODELAY */
|
||||
+
|
||||
+#ifdef SO_KEEPALIVE
|
||||
+ i = 1;
|
||||
+ setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &i, sizeof (i));
|
||||
+#endif /* SO_KEEPALIVE */
|
||||
}
|
||||
|
||||
CcXstreamClientError cc_xstream_client_connect(const char *host,
|
59
net/ccxstream/files/patch-ccxstream.c
Normal file
59
net/ccxstream/files/patch-ccxstream.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
--- ccxstream.c.orig Mon Mar 17 11:29:15 2003
|
||||
+++ ccxstream.c Tue May 15 15:02:31 2007
|
||||
@@ -1004,7 +1004,7 @@
|
||||
for (fh = 0; fh < CC_XSTREAM_MAX_OPEN_FILES; fh++)
|
||||
if (conn->open_file_handle[fh] == handle)
|
||||
break;
|
||||
- if (fh >= CC_XSTREAM_MAX_OPEN_FILES)
|
||||
+ if ( (fh >= CC_XSTREAM_MAX_OPEN_FILES) || (conn->open_file_handle[fh] <= 0) )
|
||||
{
|
||||
cc_xstream_send_error(conn, id, CC_XSTREAM_XBMSP_ERROR_INVALID_HANDLE, "Invalid file handle.");
|
||||
return 1;
|
||||
@@ -1016,10 +1016,19 @@
|
||||
}
|
||||
hlp = cc_xmalloc(rlen);
|
||||
sz = fread(hlp, 1, rlen, conn->f[fh]);
|
||||
+ if ( (sz < rlen) && ( (ferror(conn->f[fh]) != 0) || (feof(conn->f[fh]) == 0) ) )
|
||||
+ {
|
||||
+ fclose(conn->f[fh]);
|
||||
+ conn->f[fh] = NULL;
|
||||
+ cc_xstream_send_error(conn, id, CC_XSTREAM_XBMSP_ERROR_ILLEGAL_SEEK, "File read failed.");
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
cc_xstream_write_int(conn, 1 + 4 + 4 + sz);
|
||||
cc_xstream_write_byte(conn, (int)CC_XSTREAM_XBMSP_PACKET_FILE_CONTENTS);
|
||||
cc_xstream_write_int(conn, id);
|
||||
cc_xstream_write_data_string(conn, (unsigned char *)hlp, sz);
|
||||
+ }
|
||||
cc_xfree(hlp);
|
||||
return 1;
|
||||
}
|
||||
@@ -1661,6 +1670,16 @@
|
||||
setsockopt(prog->s, SOL_SOCKET, SO_REUSEPORT, (char *)&c, sizeof (c));
|
||||
#endif /* SO_REUSEPORT */
|
||||
|
||||
+#ifdef TCP_NODELAY
|
||||
+ c = 1;
|
||||
+ setsockopt(prog->s, IPPROTO_TCP, TCP_NODELAY, (char *)&c, sizeof (c));
|
||||
+#endif /* TCP_NODELAY */
|
||||
+
|
||||
+#ifdef SO_KEEPALIVE
|
||||
+ c = 1;
|
||||
+ setsockopt(prog->s, SOL_SOCKET, SO_KEEPALIVE, (char *)&c, sizeof (c));
|
||||
+#endif /* SO_KEEPALIVE */
|
||||
+
|
||||
memset(&sa, 0, sizeof (sa));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_addr = la;
|
||||
@@ -1693,6 +1712,10 @@
|
||||
c = 1;
|
||||
setsockopt(prog->bs, SOL_SOCKET, SO_BROADCAST, (char *)&c, sizeof (c));
|
||||
#endif /* SO_BROADCAST */
|
||||
+#ifdef SO_KEEPALIVE
|
||||
+ c = 1;
|
||||
+ setsockopt(prog->bs, SOL_SOCKET, SO_KEEPALIVE, (char *)&c, sizeof (c));
|
||||
+#endif /* SO_KEEPALIVE */
|
||||
|
||||
memset(&sa, 0, sizeof (sa));
|
||||
sa.sin_family = AF_INET;
|
Loading…
Reference in a new issue