projects
/
runtime.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0699f3d
)
Added silc_file_set_nonblock. Fixed FD Stream. Comment fixes.
author
Pekka Riikonen
<priikone@silcnet.org>
Mon, 28 Nov 2005 16:02:46 +0000
(16:02 +0000)
committer
Pekka Riikonen
<priikone@silcnet.org>
Mon, 28 Nov 2005 16:02:46 +0000
(16:02 +0000)
lib/silcutil/silcapputil.c
patch
|
blob
|
history
lib/silcutil/silcfdstream.c
patch
|
blob
|
history
lib/silcutil/silcfdstream.h
patch
|
blob
|
history
lib/silcutil/silcfileutil.h
patch
|
blob
|
history
lib/silcutil/silcsocketstream.h
patch
|
blob
|
history
lib/silcutil/silcstream.h
patch
|
blob
|
history
lib/silcutil/unix/silcunixutil.c
patch
|
blob
|
history
lib/silcutil/win32/silcwin32util.c
patch
|
blob
|
history
diff --git
a/lib/silcutil/silcapputil.c
b/lib/silcutil/silcapputil.c
index 606f2215539d25395c629cdac6c590eefdfc44df..98ecddaf4501df378b3f53569c6a1c7a8b0a2213 100644
(file)
--- a/
lib/silcutil/silcapputil.c
+++ b/
lib/silcutil/silcapputil.c
@@
-197,7
+197,7
@@
New pair of keys will be created. Please, answer to following questions.\n\
}
/* Generate keys */
}
/* Generate keys */
- silc_pkcs_alloc(alg, &pkcs);
+ silc_pkcs_alloc(alg,
SILC_PKCS_SILC,
&pkcs);
silc_pkcs_generate_key(pkcs, key_len_bits, rng);
/* Save public key into file */
silc_pkcs_generate_key(pkcs, key_len_bits, rng);
/* Save public key into file */
@@
-290,7
+290,7
@@
SilcBool silc_load_key_pair(const char *pub_filename,
}
if (return_pkcs) {
}
if (return_pkcs) {
- silc_pkcs_alloc((*return_public_key)->name, return_pkcs);
+ silc_pkcs_alloc((*return_public_key)->name,
SILC_PKCS_SILC,
return_pkcs);
silc_pkcs_public_key_set(*return_pkcs, *return_public_key);
silc_pkcs_private_key_set(*return_pkcs, *return_private_key);
}
silc_pkcs_public_key_set(*return_pkcs, *return_public_key);
silc_pkcs_private_key_set(*return_pkcs, *return_private_key);
}
@@
-326,7
+326,7
@@
SilcBool silc_show_public_key(const char *pub_filename)
fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
- if (silc_pkcs_alloc(public_key->name, &pkcs)) {
+ if (silc_pkcs_alloc(public_key->name,
SILC_PKCS_SILC,
&pkcs)) {
key_len = silc_pkcs_public_key_set(pkcs, public_key);
silc_pkcs_free(pkcs);
}
key_len = silc_pkcs_public_key_set(pkcs, public_key);
silc_pkcs_free(pkcs);
}
diff --git
a/lib/silcutil/silcfdstream.c
b/lib/silcutil/silcfdstream.c
index d1fc6b534dd942660b52cd8e7cb46b36d492476b..c47aae8e393f0e93ef9f367dbe322c8c541e0fec 100644
(file)
--- a/
lib/silcutil/silcfdstream.c
+++ b/
lib/silcutil/silcfdstream.c
@@
-73,7
+73,7
@@
SilcStream silc_fd_stream_create2(int read_fd, int write_fd,
{
SilcFDStream stream;
{
SilcFDStream stream;
- if (read_fd < 1
&& write_fd < 1
)
+ if (read_fd < 1)
return NULL;
stream = silc_calloc(1, sizeof(*stream));
return NULL;
stream = silc_calloc(1, sizeof(*stream));
@@
-85,19
+85,19
@@
SilcStream silc_fd_stream_create2(int read_fd, int write_fd,
stream->ops = &silc_fd_stream_ops;
stream->schedule = schedule;
stream->fd1 = read_fd;
stream->ops = &silc_fd_stream_ops;
stream->schedule = schedule;
stream->fd1 = read_fd;
- stream->fd
1
= write_fd;
+ stream->fd
2
= write_fd;
/* Schedule the file descriptors */
if (write_fd > 0) {
silc_schedule_task_add_fd(schedule, write_fd, silc_fd_stream_io, stream);
/* Schedule the file descriptors */
if (write_fd > 0) {
silc_schedule_task_add_fd(schedule, write_fd, silc_fd_stream_io, stream);
- silc_
net_set_sock
et_nonblock(write_fd);
+ silc_
file_s
et_nonblock(write_fd);
}
if (read_fd > 0) {
silc_schedule_task_add_fd(schedule, read_fd, silc_fd_stream_io, stream);
silc_schedule_set_listen_fd(schedule, read_fd, SILC_TASK_READ, FALSE);
}
if (read_fd > 0) {
silc_schedule_task_add_fd(schedule, read_fd, silc_fd_stream_io, stream);
silc_schedule_set_listen_fd(schedule, read_fd, SILC_TASK_READ, FALSE);
- silc_
net_set_sock
et_nonblock(read_fd);
+ silc_
file_s
et_nonblock(read_fd);
if (write_fd < 1)
if (write_fd < 1)
-
write_fd = read_fd
;
+
stream->fd2 = stream->fd1
;
}
return stream;
}
return stream;
@@
-215,10
+215,14
@@
SilcBool silc_fd_stream_close(SilcStream stream)
if (!SILC_IS_FD_STREAM(fd_stream))
return FALSE;
if (!SILC_IS_FD_STREAM(fd_stream))
return FALSE;
- if (fd_stream->fd1 > 0)
+ if (fd_stream->fd1 > 0)
{
silc_file_close(fd_stream->fd1);
silc_file_close(fd_stream->fd1);
- if (fd_stream->fd2 > 0 && fd_stream->fd2 != fd_stream->fd1)
+ silc_schedule_unset_listen_fd(fd_stream->schedule, fd_stream->fd1);
+ }
+ if (fd_stream->fd2 > 0 && fd_stream->fd2 != fd_stream->fd1) {
silc_file_close(fd_stream->fd2);
silc_file_close(fd_stream->fd2);
+ silc_schedule_unset_listen_fd(fd_stream->schedule, fd_stream->fd2);
+ }
return TRUE;
}
return TRUE;
}
@@
-233,6
+237,8
@@
void silc_fd_stream_destroy(SilcStream stream)
return;
silc_fd_stream_close(stream);
return;
silc_fd_stream_close(stream);
+ silc_schedule_task_del_by_fd(fd_stream->schedule, fd_stream->fd1);
+ silc_schedule_task_del_by_fd(fd_stream->schedule, fd_stream->fd2);
silc_free(stream);
}
silc_free(stream);
}
diff --git
a/lib/silcutil/silcfdstream.h
b/lib/silcutil/silcfdstream.h
index 3acb8cecaf78a135f1c50ddb05c781d818b5014f..9904fcac0dafcffe8290a8242084a0340fcb8ce8 100644
(file)
--- a/
lib/silcutil/silcfdstream.h
+++ b/
lib/silcutil/silcfdstream.h
@@
-26,6
+26,9
@@
* interface should be used only with real file descriptors, not with
* sockets. Use the SILC Socket Stream for sockets.
*
* interface should be used only with real file descriptors, not with
* sockets. Use the SILC Socket Stream for sockets.
*
+ * SILC File Descriptor Stream is not thread-safe. If same stream must be
+ * used in multithreaded environment concurrency control must be employed.
+ *
***/
#ifndef SILCFDSTREAM_H
***/
#ifndef SILCFDSTREAM_H
diff --git
a/lib/silcutil/silcfileutil.h
b/lib/silcutil/silcfileutil.h
index a1ccd3049953cf54e80f241edf980383893f8ef4..3437870aa36cc30e7bc1fe40d532f869cc46e661 100644
(file)
--- a/
lib/silcutil/silcfileutil.h
+++ b/
lib/silcutil/silcfileutil.h
@@
-100,6
+100,19
@@
int silc_file_write(int fd, const char *buffer, SilcUInt32 len);
***/
int silc_file_close(int fd);
***/
int silc_file_close(int fd);
+/****f* silcutil/SilcNetAPI/silc_file_set_nonblock
+ *
+ * SYNOPSIS
+ *
+ * int silc_file_set_nonblock(int fd);
+ *
+ * DESCRIPTION
+ *
+ * Sets the file descriptor to non-blocking mode.
+ *
+ ***/
+int silc_file_set_nonblock(int fd);
+
/****f* silcutil/SilcFileUtilAPI/silc_file_readfile
*
* SYNOPSIS
/****f* silcutil/SilcFileUtilAPI/silc_file_readfile
*
* SYNOPSIS
diff --git
a/lib/silcutil/silcsocketstream.h
b/lib/silcutil/silcsocketstream.h
index dec1401912fbe6dd614aecba3997bbfd32399e6f..565190966b9eba97198fa2227c4a787aa9a3f141 100644
(file)
--- a/
lib/silcutil/silcsocketstream.h
+++ b/
lib/silcutil/silcsocketstream.h
@@
-26,6
+26,9
@@
* Stream provides also Quality of Service (QoS) support that can be used
* to control the throughput of the stream.
*
* Stream provides also Quality of Service (QoS) support that can be used
* to control the throughput of the stream.
*
+ * SILC Socket Stream is not thread-safe. If the same socket stream must be
+ * used in multithreaded environment concurrency control must be employed.
+ *
***/
#ifndef SILCSOCKETSTREAM_H
***/
#ifndef SILCSOCKETSTREAM_H
diff --git
a/lib/silcutil/silcstream.h
b/lib/silcutil/silcstream.h
index 31c6d078942933daa27f1286945951ba4e545cc5..e3278ab30ba260870cf2f4f2f83e2342d2be52c3 100644
(file)
--- a/
lib/silcutil/silcstream.h
+++ b/
lib/silcutil/silcstream.h
@@
-26,6
+26,10
@@
* other stream API derived from this API can use this same interface for
* sending and receiving.
*
* other stream API derived from this API can use this same interface for
* sending and receiving.
*
+ * Note that stream implementations usually are not thread-safe. Always
+ * verify whether a stream implementation is thread-safe by checking their
+ * corresponding documentation.
+ *
***/
#ifndef SILCSTREAM_H
***/
#ifndef SILCSTREAM_H
diff --git
a/lib/silcutil/unix/silcunixutil.c
b/lib/silcutil/unix/silcunixutil.c
index 300beff0b391571d13d637c87de9ec13d3c46a9b..93a5fdd2b3c0a4906f0bcd5cbfa9bc9ba04b6cbe 100644
(file)
--- a/
lib/silcutil/unix/silcunixutil.c
+++ b/
lib/silcutil/unix/silcunixutil.c
@@
-176,3
+176,9
@@
int silc_gettimeofday(struct timeval *p)
{
return gettimeofday(p, NULL);
}
{
return gettimeofday(p, NULL);
}
+
+int silc_file_set_nonblock(int fd)
+{
+ return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
+}
+
diff --git
a/lib/silcutil/win32/silcwin32util.c
b/lib/silcutil/win32/silcwin32util.c
index 7bc2d69a98981964d1109786057a0bf657252052..45c45e6cb2f5be1980ca6f44b457857b70ff4b62 100644
(file)
--- a/
lib/silcutil/win32/silcwin32util.c
+++ b/
lib/silcutil/win32/silcwin32util.c
@@
-73,3
+73,8
@@
char *silc_get_real_name(void)
{
return silc_get_username();
}
{
return silc_get_username();
}
+
+int silc_file_set_nonblock(int fd)
+{
+ return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
+}