fix select issue in ftpd and lwip_select. cleanup assert information output in lwip.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@148 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
fee61e2c2a
commit
48c747e0c8
|
@ -1,8 +1,7 @@
|
|||
#include <rtthread.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <dfs_posix.h>
|
||||
#include <lwip/sockets.h>
|
||||
|
||||
|
@ -107,7 +106,7 @@ int build_full_path(struct ftp_session* session, char* path, char* new_path, siz
|
|||
strcpy(new_path, path);
|
||||
else
|
||||
{
|
||||
rt_sprintf(new_path, "%s\\%s", session->currentdir, path);
|
||||
rt_sprintf(new_path, "%s/%s", session->currentdir, path);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -115,8 +114,8 @@ int build_full_path(struct ftp_session* session, char* path, char* new_path, siz
|
|||
|
||||
void ftpd_thread_entry(void* parameter)
|
||||
{
|
||||
int sockfd;
|
||||
int numbytes;
|
||||
int sockfd, maxfdp1;
|
||||
struct sockaddr_in local;
|
||||
fd_set readfds, tmpfds;
|
||||
struct ftp_session* session;
|
||||
|
@ -143,8 +142,21 @@ void ftpd_thread_entry(void* parameter)
|
|||
FD_SET(sockfd, &readfds);
|
||||
for(;;)
|
||||
{
|
||||
/* get maximum fd */
|
||||
maxfdp1 = sockfd + 1;
|
||||
session = session_list;
|
||||
while (session != RT_NULL)
|
||||
{
|
||||
if (maxfdp1 < session->sockfd + 1)
|
||||
maxfdp1 = session->sockfd + 1;
|
||||
|
||||
FD_SET(session->sockfd, &readfds);
|
||||
session = session->next;
|
||||
}
|
||||
|
||||
tmpfds=readfds;
|
||||
select(0, &tmpfds, 0, 0, 0);
|
||||
if (select(maxfdp1, &tmpfds, 0, 0, 0) == 0) continue;
|
||||
|
||||
if(FD_ISSET(sockfd, &tmpfds))
|
||||
{
|
||||
int com_socket;
|
||||
|
@ -600,7 +612,7 @@ err1:
|
|||
}
|
||||
else if(str_begin_with(buf, "CDUP")==0)
|
||||
{
|
||||
rt_sprintf(filename, "%s\\%s", session->currentdir, "..");
|
||||
rt_sprintf(filename, "%s/%s", session->currentdir, "..");
|
||||
|
||||
rt_sprintf(sbuf, "250 Changed to directory \"%s\"\r\n", filename);
|
||||
send(session->sockfd, sbuf, strlen(sbuf), 0);
|
||||
|
@ -738,13 +750,13 @@ void ftpd_start()
|
|||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
tid = rt_thread_create("ftp",
|
||||
tid = rt_thread_create("ftpd",
|
||||
ftpd_thread_entry, RT_NULL,
|
||||
1024, 30, 5);
|
||||
4096, 30, 5);
|
||||
if (tid != RT_NULL) rt_thread_startup(tid);
|
||||
}
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
FINSH_FUNCTION_EXPORT(ftpd_start, start ftp server);
|
||||
FINSH_FUNCTION_EXPORT(ftpd_start, start ftp server)
|
||||
#endif
|
||||
|
|
|
@ -966,8 +966,7 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
|||
msectimeout = 1;
|
||||
}
|
||||
|
||||
|
||||
if (msectimeout > 0 && sys_arch_timeouts() == NULL){
|
||||
if (sys_arch_timeouts() == NULL){
|
||||
/* it's not a lwip thread, use os semaphore with timeout to handle it */
|
||||
i = sys_arch_sem_wait(select_cb.sem, msectimeout);
|
||||
if (i == SYS_ARCH_TIMEOUT) i = 0;
|
||||
|
|
|
@ -314,6 +314,7 @@ void sys_arch_unprotect(sys_prot_t pval)
|
|||
|
||||
void sys_arch_assert(const char* file, int line)
|
||||
{
|
||||
rt_kprintf("Assertion: %d in %s\n", line, file);
|
||||
rt_kprintf("\nAssertion: %d in %s, thread %s\n", line, file,
|
||||
rt_thread_self()->name);
|
||||
RT_ASSERT(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue