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:
bernard.xiong committed 2009-11-03 23:59:30 +00:00
1 parent fee61e2c2a
commit 48c747e0c8
3 files changed
+82 -70

No files matched your search

+31 -19
View File
@@ -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;
@@ -199,7 +211,7 @@ void ftpd_thread_entry(void* parameter)
closesocket(session->sockfd);
ftp_close_session(session);
}
}
}
}
session = next;
@@ -222,7 +234,7 @@ int do_list(char* directory, int sockfd)
#endif
dirp = opendir(directory);
if (dirp == NULL)
if (dirp == NULL)
{
line_length = rt_sprintf(line_buffer, "500 Internal Error\r\n");
send(sockfd, line_buffer, line_length, 0);
@@ -234,7 +246,7 @@ int do_list(char* directory, int sockfd)
entry = readdir(dirp);
if (entry == NULL) break;
rt_sprintf(line_buffer, "%s/%s", directory, entry->d_name);
rt_sprintf(line_buffer, "%s/%s", directory, entry->d_name);
#ifdef _WIN32
if (_stat(line_buffer, &s) ==0)
#else
@@ -258,24 +270,24 @@ int do_simple_list(char* directory, int sockfd)
DIR* dirp;
struct dirent* entry;
char line_buffer[256], line_length;
dirp = opendir(directory);
if (dirp == NULL)
if (dirp == NULL)
{
line_length = rt_sprintf(line_buffer, "500 Internal Error\r\n");
send(sockfd, line_buffer, line_length, 0);
return -1;
}
while (1)
{
entry = readdir(dirp);
if (entry == NULL) break;
line_length = rt_sprintf(line_buffer, "%s\r\n", entry->d_name);
send(sockfd, line_buffer, line_length, 0);
}
return 0;
}
@@ -354,7 +366,7 @@ int ftp_process_request(struct ftp_session* session, char *buf)
else if(str_begin_with(buf, "PASS")==0)
{
rt_kprintf("%s sent password \"%s\"\n", inet_ntoa(session->remote.sin_addr), parameter_ptr);
if (strcmp(parameter_ptr, FTP_PASSWORD)==0 ||
if (strcmp(parameter_ptr, FTP_PASSWORD)==0 ||
session->is_anonymous == RT_TRUE)
{
// password correct
@@ -566,7 +578,7 @@ err1:
int file_size;
build_full_path(session, parameter_ptr, filename, 256);
file_size = ftp_get_filesize(filename);
if( file_size == -1)
{
@@ -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
File diff suppressed because it is too large. Load diff
+12 -11
View File
@@ -34,7 +34,7 @@ sys_sem_t sys_sem_new(u8_t count)
#if SYS_DEBUG
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Create sem: %s \n",thread->name, tname));
}
@@ -51,7 +51,7 @@ void sys_sem_free(sys_sem_t sem)
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Delete sem: %s \n",thread->name,
sem->parent.parent.name));
}
@@ -68,7 +68,7 @@ void sys_sem_signal(sys_sem_t sem)
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Release signal: %s , %d\n",thread->name,
sem->parent.parent.name, sem->value));
}
@@ -91,7 +91,7 @@ u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Wait sem: %s , %d\n",thread->name,
sem->parent.parent.name, sem->value));
}
@@ -132,7 +132,7 @@ sys_mbox_t sys_mbox_new(int size)
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Create mbox: %s \n",thread->name, tname));
}
#endif
@@ -148,7 +148,7 @@ void sys_mbox_free(sys_mbox_t mbox)
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Delete mbox: %s\n",thread->name,
mbox->parent.parent.name));
}
@@ -165,7 +165,7 @@ void sys_mbox_post(sys_mbox_t mbox, void *msg)
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Post mail: %s ,0x%x\n",thread->name,
mbox->parent.parent.name, (rt_uint32_t)msg));
}
@@ -182,7 +182,7 @@ err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg)
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Post mail: %s ,0x%x\n",thread->name,
mbox->parent.parent.name, (rt_uint32_t)msg));
}
@@ -220,7 +220,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Fetch mail: %s , 0x%x\n",thread->name,
mbox->parent.parent.name, *(rt_uint32_t **)msg));
}
@@ -249,7 +249,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg)
{
struct rt_thread *thread;
thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Fetch mail: %s , 0x%x\n",thread->name,
mbox->parent.parent.name, *(rt_uint32_t **)msg));
}
@@ -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);
}