Andre Noll [Sun, 25 Nov 2007 22:28:09 +0000 (23:28 +0100)]
com_addatt: Minor improvements.
- Use get_attribute_bitnum_by_name() instead of open-coding.
- Use new error code E_ATT_TABLE_FULL.
- Move definition of objs[ATTCOL_NAME] down to where it is needed.
- Kill FIXME comment: We can not use find_greatest_att_bitnum() here.
Andre Noll [Sun, 25 Nov 2007 12:36:37 +0000 (13:36 +0100)]
Introduce tcp_connect().
This replaces get_host_info(). The two callers of the latter,
client_connect() and http_recv_open(), did exactly the same, namely
initializing a struct sockaddr_in which was then used for PARA_CONNECT().
So move this common code to tcp_connect(). Additional benefit of this
is that the only remaining callers of init_sockaddr() are in net.c, so
make this function static.
Andre Noll [Sun, 25 Nov 2007 11:08:24 +0000 (12:08 +0100)]
Get rid of E_SEND.
This patch also simplifies sendall() a bit and fixes two bugs in
add_one_audio_file():
- If the check for existence of a hash sister failed, we missed
to unmap the audio file.
- If an error occurred we send out a message to the client. If
this message can not be sent (because the client terminated
the connection) we returned success anyway and happily
tried to add the next audio file.
Andre Noll [Fri, 23 Nov 2007 09:40:16 +0000 (10:40 +0100)]
In handle_connect() we really need a blocking fd for the client.
At least on NetBSD the fd returned by accept() might be in non-blocking
mode. So introduce mark_fd_blocking() and use it in handle_connect().
Andre Noll [Sun, 18 Nov 2007 19:59:49 +0000 (20:59 +0100)]
Fix handling of invalid entries in the score table.
It may happen that the score table contains references to files that
no longer exist in the file system. The current code fails badly in
this case.
In open_next_audio_file(), if the file corresponding to the next
entry in the score table can not be opened, delete this entry from
the score table and try the next entry.
If the score table becomes empty, send NO_ADMISSIBLE_FILES back to para_server
and make recv_afs_result() switch to stop mode in this case.
Andre Noll [Tue, 13 Nov 2007 19:08:06 +0000 (20:08 +0100)]
Fix tv_divide().
The old code contained an integer overflow which caused the mp3 audio
format handler to compute the chunk of large mp3 files incorrectly.
Moreover, the code was more complicated than necessary. So replace it
by a simple calculation which just transforms the given struct timeval
into its number of microseconds, does the division and transforms
the quotient back to a struct timeval.
Thanks to Gerrit Renker for pointing out the problem.
Andre Noll [Sat, 3 Nov 2007 21:04:04 +0000 (22:04 +0100)]
Store chunk info in the afhi column rather than in the chunk column.
As the afhi column is mmapped, the chunk info is now available to
the ls command. The disk-storage column "chunks" only contains the
chunk table which allows to get rid of load_chunk_info() and
save_chunk_info().
Andre Noll [Fri, 2 Nov 2007 00:00:42 +0000 (01:00 +0100)]
score.c: Use the new OSL_DONT_FREE flag for the aft column.
The score tables stores in one of its columns a pointer to
a row in the audio file table. This means for each admissible
file we're allocating space for a void* pointer to store the
aft pointer.
It's simpler and probably faster to store the afs pointer directly,
but of course that pointer must not be freed by the osl.
Andre Noll [Thu, 1 Nov 2007 23:49:03 +0000 (00:49 +0100)]
Fix duplicate afs event add.
This bug hits if a request to update an existing audio file
is made. The old code caused an AFHI_CHANGE event and then
did "goto out;" which raises nother event (AUDIO_FILE_ADD).
Fix it by moving the event-raising code some lines up.
Andre Noll [Thu, 1 Nov 2007 17:43:07 +0000 (18:43 +0100)]
Kill duplicate num_played status item.
In fact, the two num_played values were different: The first
was the number of audio files streamed by para_server so far,
and the second one was the num_played value from struct afs_info.
The former is also contained in the output of com_si, so get
rid of it in the stat output.